Skip to content

The agent's turn followed as it happens: thinking, timed steps, and a stream a page picks up again - #17

Merged
WaylandYang merged 3 commits into
devfrom
feat/agent-stream
Oct 18, 2026
Merged

WaylandYang merged 3 commits into
devfrom
feat/agent-stream

Conversation

@WaylandYang

Copy link
Copy Markdown
Contributor

What changes

Stream. A turn is now a numbered event log kept on the site while it runs. POST /api/sessions/:id/agent only begins the turn ({ turn, now }); GET /api/sessions/:id/agent/events?turn=… streams it as server-sent events from the start or from Last-Event-ID. A reload, a second tab or a dropped line carries on where it was instead of polling every 1.5 s. Text and thinking pieces that arrive close together are merged before they are numbered. A turn taken up again after the runner reconnects is told afresh.

Thinking. pi is asked to think where the provider's way is known: OpenRouter (reasoning: { effort }) and DeepSeek (thinking). A new admin setting covers auto / off / low / medium / high; other endpoints only think when an admin turns it on. Thinking is streamed as think events and kept as a thought item, with its duration. pi only emits thinking_end with the message, so the runner closes a thought as soon as the reply's text or a tool call begins.

Steps. Each tool result now has a duration, and an edit carries pi's unified patch. Long tool calls report how much has been written (drafting). A retried model call is shown, and spend is pushed after each model call. When the provider refuses a turn for good (402, 401/403, 429), the learner is told why instead of seeing a generic failure.

Panel. One status line sits under a running turn. It shows what the agent is doing (thinking / running X / writing file / replying / looking at a result), with a mark that moves differently for each, plus elapsed time and approximate tokens. The live thinking can be opened while it streams. A turn's work folds into a line such as "ran 3 commands, read 2 files, made 1 change · 1 failed", with the total time. Each step shows its status, duration, exit code and a coloured diff for edits. Scrollbars are slim throughout.

Tests

  • pnpm typecheck, pnpm test (40 passing, with FDEGYM_TEST_REQUIRE_DB=1 against Postgres 16) and pnpm build, all run in node:22.
  • New tests:
    • the runner: thinking asked for and streamed, then kept whole; nothing asked for when thinking is off; an edit's patch.
    • the site: event numbering and merging, following from part-way and after the end, step durations, spend, an error ending the turn, and failure messages by status.
  • Tried by hand on docker compose with a real model (DeepSeek deepseek-flash via api.deepseek.com) on the campus_booking case:
    • thinking captured and shown;
    • read, bash and edit steps with durations;
    • pi's real patch rendered as a diff;
    • a page reloaded mid-command picks the turn up again without duplicating it.

Notes

  • The relay is unchanged apart from pushing spend after each call.
  • Old conversations still render: items without ms or patch fall back as before.

🤖 Generated with Claude Code

WaylandYang and others added 3 commits October 11, 2026 13:55
The tagline: the online judge for the LLM era
… and how long it took, and a page that reloads picks it up again

A turn is told to every page watching it as numbered events, kept on the site while the turn runs:
GET /api/sessions/:id/agent/events streams them as server-sent events, from the start or from the
last one a page had (Last-Event-ID), so a reload, a second tab or a dropped line carries on where
it was instead of asking every second and a half. Sending a message now only begins the turn.

pi is asked to think where the provider's way of asking is known (OpenRouter, DeepSeek; an admin
can choose low, medium, high or off), and what the model thinks is passed on as it comes and kept
whole, with how long it took. Tool calls carry their times, an edit its diff, and a long write
how much of it has been written; failed model calls being tried again are said, and what the run
has spent is told after each call. A provider that refuses the turn for good says why (out of
credit, the key refused, too many requests).

In the panel: one line under a running turn says what the agent is doing, for how long, and about
how many tokens it has written; thinking opens underneath; each step shows how it went and how
long it took, with exit codes and diffs; a turn's work folds into a line that says what it came to.
Scrollbars are slim throughout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@WaylandYang
WaylandYang merged commit 927321f into dev Oct 18, 2026
5 checks passed
@WaylandYang
WaylandYang deleted the feat/agent-stream branch October 18, 2026 03:30
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