small gleam coding and persistent agent daemon with a detachable cli and a canvas ui albedo.sh

chat completions: openrouter's repeated finish chunk fails the turn #38

Closed zzstoatzz.io
Closed opened by zzstoatzz.io

On main @ 534e49eb, an openai profile pointed at OpenRouter (https://openrouter.ai/api/v1, protocol: chat_completions, model deepseek/deepseek-v4.1-flash) fails every turn with:

InvalidEvent("chat choice after finish reason")

OpenRouter's stream sends the finish_reason: "stop" chunk twice — the second one repeats the choice (empty delta) and carries usage — and apply_chunk in src/albedo/openai_api/chat.gleam:314 rejects any choice once finish is set. Accepting an empty-delta choice whose finish matches would cover it.

Workaround: protocol: responses on the same profile works.

b4f7720c2dde07f936619da3f7dea1a7967dcf6f i havent tested it just yet since im working through a bunch of stuff

deepseek v4 (not v4.1) flash through openrouter breaks with the same error for me, regardless of protocol running the latest commit, b274c034e64263a48961adcdf736f1e0cc838fd6 v4.1 works with responses, chat_completions still broken on latest

this might be useless information

i’m awake now to properly test and get a fix out thanks

5fdfb65303e68be7fb9c03fd31ca1bfa6abf9cfb fully tested it live with deepseek and then claude, also added openrouter as its own provider

hell yea ty 😃

tested and fixed properly now

Sign up or Sign in to add to the discussion.