Skip to content

fix(runtime+frontend): stream codex turns live; SSO-off auth endpoints return JSON#615

Merged
zakahan merged 2 commits into
mainfrom
worktree-codex-streaming
Jun 16, 2026
Merged

fix(runtime+frontend): stream codex turns live; SSO-off auth endpoints return JSON#615
zakahan merged 2 commits into
mainfrom
worktree-codex-streaming

Conversation

@yaozheng-fang

@yaozheng-fang yaozheng-fang commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Two fixes that together make the runtime="codex" demo work end-to-end in veadk frontend.

1. Stream codex turns incrementally (runtime)

The codex runtime called await thread.run(prompt), which collects the entire turn before returning, then emitted all ADK events at once. Over /run_sse nothing reached the client mid-turn, so (next to adk's live streaming) codex looked frozen for tens of seconds.

Fix (runtime layer only — no server/Runner changes): consume the Codex turn stream and emit ADK events as each item completes, honoring BaseRuntime's async-generator contract.

  • translate.py: split result_to_events into a reusable per-item item_to_events; result_to_events composes it (+ keeps the final_response fallback).
  • runtime.py: thread.turn(prompt).stream() → per ItemCompletedNotification, yield item_to_events(item); raise on a failed TurnCompletedNotification.

Verified (timestamps per yielded event): reasoning + tool steps now arrive mid-turn (~7s) instead of all at the end (~16s).

2. SSO-off auth endpoints return JSON (frontend server)

With SSO not configured, the SPA still fetches /web/auth-config and /oauth2/userinfo on startup; both fell through to the StaticFiles SPA fallback and returned the HTML shell, so await res.json() threw (Unexpected token '<') and the app hung on a blank boot screen.

Fix: always register /web/auth-config (empty providers when SSO off) and, when SSO is off, add /oauth2/userinfo → 401 JSON, so the SPA's identity check resolves cleanly.

Verified end-to-end

veadk frontend --agents-dir examples/force_demo (no SSO) → app loads; codex_runtime agent streams THOUGHT then text live over /run_sse.

The codex runtime called `await thread.run(prompt)`, which blocks until the
whole turn (reasoning + tool calls + final message) completes, then emitted all
ADK events at once. Over /run_sse this left the client silent for the entire
turn — next to adk's live streaming, codex looked frozen for tens of seconds
before everything appeared at the end.

Consume the Codex turn stream instead (`thread.turn(...).stream()`) and emit
ADK events as each item completes, honoring BaseRuntime's async-generator
contract truly incrementally. No server/Runner changes — purely the runtime
layer, so other runtimes keep the same streaming contract.

- translate.py: split result_to_events into a reusable per-item
  `item_to_events`; result_to_events now composes it (+ keeps the
  final_response fallback for the batch path).
- runtime.py: stream ItemCompletedNotification -> item_to_events; raise on a
  failed TurnCompletedNotification.

Verified: reasoning + tool-call events arrive mid-turn (~7s) instead of all at
the end (~16s); thinking renders live.
…config

When SSO is not configured, the SPA still fetches /web/auth-config and
/oauth2/userinfo on startup; those paths fell through to the StaticFiles SPA
fallback and returned the HTML shell, so the app's `await res.json()` threw
("Unexpected token '<'") and it hung on a blank boot screen.

Always register /web/auth-config (empty provider list when SSO is off) and, when
SSO is off, add a /oauth2/userinfo route that returns 401 JSON, so the SPA's
identity check resolves cleanly and renders its normal no-login UI.

Needed for the codex-runtime demo (veadk frontend without SSO) to load.
@yaozheng-fang yaozheng-fang changed the title fix(runtime): stream codex turns incrementally so thinking shows live fix(runtime+frontend): stream codex turns live; SSO-off auth endpoints return JSON Jun 16, 2026
@zakahan zakahan merged commit 4c6e7b0 into main Jun 16, 2026
16 checks passed
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.

2 participants