Skip to content

feat: streamed usage on finish chunk and pageUrl skill arming in sessions - #125

Merged
its-janghoon merged 3 commits into
developfrom
feat/agent-followups
Oct 19, 2026
Merged

its-janghoon merged 3 commits into
developfrom
feat/agent-followups

Conversation

@its-janghoon

Copy link
Copy Markdown
Member

What's done

  • /v1/chat/completions streaming: the finish chunk now carries usage in the same OpenAI shape as the JSON body (one shared toWireUsage). If the provider reports usage only per step, the last step-finish usage is used. Before this, streamed callers (browser memory runs) recorded 0 tokens.
  • Agent sessions: the session prompt body takes an optional pageUrl. It is stored on the user message (UserMessage.pageUrl) and passed to armedSkills as url, so skills with urls: globs arm in agent sessions the same way they do on redrob_context.page_url.
  • SDK v2 client: regenerated, but only the pageUrl hunks are committed. packages/client and packages/redrob/schema regenerate with no diff.
  • docs/LOCAL-ENGINE-API.md: documents pageUrl.

What's not done

  • The full SDK v2 regeneration is left out. develop's src/v2/gen is already behind (channel and bridged-app types), and regenerating it fully breaks tsc because BridgedApp/BridgedAppList clash with names src/v2/client.ts already exports. That is its own fix.
  • No new tests (per the repo owner's rule).

What to review

  • toChunks in packages/server/src/handlers/chat-completion.ts: when the finish event has no usage, the last step-finish usage stands in.
  • packages/redrob/src/session/prompt.ts: pageUrl is trimmed and stored only when it is not empty, and arming reads it from lastUser.

Intentions

  • The engine never asks the browser for the tab URL. The caller sends it with the prompt, so no message waits on a browser round trip.

Local gate (bun 1.3.14): frozen install, typecheck, test:httpapi, core tests, engine tests (3506 pass, 0 fail) all exit 0.

The browser runs memory extraction over streaming /v1/chat/completions,
and the stream never carried usage: the JSON body mapped it, the finish
chunk did not. Memory runs therefore recorded 0 tokens.

The finish chunk now carries `usage` in the same OpenAI shape the JSON
body uses (one shared mapping), falling back to the last step-finish
usage when the provider reports only per step. ChatCompletionChunk
already declared `usage`, so the contract and SDK are unchanged.
Agent sessions armed skills by keywords only; the URL half waited for a
tab URL the engine did not hold. The session prompt body now takes an
optional `pageUrl`, stored on the user message, and the loop passes it
to SystemPrompt.armedSkills -- the same SkillArming.arm the
chat-completions route runs on `redrob_context.page_url`.

The prompt body and UserMessage schemas gained an optional field, so the
generated SDK clients need `bun run generate` before a caller can send it
typed.
Only the pageUrl hunks are taken. A full regeneration also pulls in
channel and bridged-app types that develop has not regenerated yet, and
those collide with names src/v2/client.ts already exports.
@its-janghoon
its-janghoon merged commit f16ef90 into develop Oct 19, 2026
17 checks passed
@its-janghoon
its-janghoon deleted the feat/agent-followups branch October 19, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant