feat: relay streamed reasoning, render tool params, add execute tool #35

Merged
sam merged 2 commits from feat/relay-streamed-reasoning into main 2026-10-18 15:19:50 +00:00
Collaborator

Replaces #34 (closed; head branch renamed to a conventional name). Review findings from #34 are resolved in 2d5571c on top of the original work.


Fixes three operator-visible gaps in brainless:

  1. Read params were invisible in the timeline. The ACP tool-call payload carried the model's head/tail args and {"output": ...} results, but clients render a read from rawInput.offset/limit and result text from a content key, so the Paseo timeline showed a bare read with no line range and no content. Built-in read calls now mirror head/tail as offset/limit (plus the standard locations entry) and all built-in tool results carry a content key alongside output. Model-facing schemas are unchanged.

  2. Reasoning blocks never rendered. Prompt skipped every partial event, and reasoning models (melious's Responses path) deliver thinking only as streamed deltas — the terminal response omits it — so reasoning was dropped entirely. Thought deltas are now relayed live as agent_thought_chunk updates (Paseo coalesces consecutive chunks into one block). Answer-text deltas stay buffered until the round's final event confirms the turn survived, preserving the budget-crossing guarantee (no partially delivered answer marked cancelled).

  3. No built-in command tool. Added an always-visible execute(command, cwd?, timeout?) tool: runs sh -c in the session working directory, returns combined output + exit code as data, caps output at 100 KiB, and bounds runtime (default 30s, max 300s) by killing the whole process group so orphaned grandchildren can't hold Wait open.

Tests: new e2e coverage for streamed reasoning (TestACPPromptStreamsReasoningDeltas) and read param rendering (TestACPToolCallReadParamsRenderable), plus an execute-tool suite. go test -race ./... and golangci-lint run are clean.

Known limitation (deliberately out of scope): the chat-completions fallback path still cannot surface reasoning — ADK's openaimodel reads chat-completions responses for text/refusals/tool calls only, and reasoning_content isn't in openai-go's types. The primary Responses path is fixed.

Replaces #34 (closed; head branch renamed to a conventional name). Review findings from #34 are resolved in 2d5571c on top of the original work. --- Fixes three operator-visible gaps in brainless: 1. **Read params were invisible in the timeline.** The ACP tool-call payload carried the model's `head`/`tail` args and `{"output": ...}` results, but clients render a read from `rawInput.offset`/`limit` and result text from a `content` key, so the Paseo timeline showed a bare `read` with no line range and no content. Built-in read calls now mirror head/tail as offset/limit (plus the standard locations entry) and all built-in tool results carry a `content` key alongside `output`. Model-facing schemas are unchanged. 2. **Reasoning blocks never rendered.** `Prompt` skipped every partial event, and reasoning models (melious's Responses path) deliver thinking only as streamed deltas — the terminal response omits it — so reasoning was dropped entirely. Thought deltas are now relayed live as `agent_thought_chunk` updates (Paseo coalesces consecutive chunks into one block). Answer-text deltas stay buffered until the round's final event confirms the turn survived, preserving the budget-crossing guarantee (no partially delivered answer marked cancelled). 3. **No built-in command tool.** Added an always-visible `execute(command, cwd?, timeout?)` tool: runs `sh -c` in the session working directory, returns combined output + exit code as data, caps output at 100 KiB, and bounds runtime (default 30s, max 300s) by killing the whole process group so orphaned grandchildren can't hold `Wait` open. Tests: new e2e coverage for streamed reasoning (`TestACPPromptStreamsReasoningDeltas`) and read param rendering (`TestACPToolCallReadParamsRenderable`), plus an execute-tool suite. `go test -race ./...` and `golangci-lint run` are clean. Known limitation (deliberately out of scope): the chat-completions fallback path still cannot surface reasoning — ADK's openaimodel reads chat-completions responses for text/refusals/tool calls only, and `reasoning_content` isn't in openai-go's types. The primary Responses path is fixed.
feat: relay streamed reasoning, render tool params, add execute tool
All checks were successful
code-review / Agent review (pull_request) Successful in 8s
7a8ed6df74
Three fixes for what an operator sees and can do with a brainless agent:

- Reasoning that arrives only as streamed deltas (melious's Responses path
  omits it from the terminal response) is now relayed live as
  agent_thought_chunk updates; previously all partial events were skipped,
  so thinking blocks never rendered. Answer-text deltas stay buffered until
  the round's final event confirms the turn survived, preserving the
  budget-crossing guarantee (no partially delivered answer marked
  cancelled), and the final event adds only the unstreamed reasoning tail.
- Built-in read calls mirror their line range under the ACP offset/limit
  keys (plus the standard locations entry) and built-in tool results carry
  a "content" key alongside "output", so the client timeline shows
  which part of a file an agent read and what it got back instead of a
  bare tool name. The model-facing schemas are unchanged.
- New always-visible execute tool runs a command via sh -c in the session
  working directory, with a bounded timeout that kills the whole process
  tree (process group), capped output, and the exit code returned as data.
fix: resolve PR #34 review findings
All checks were successful
code-review / Agent review (pull_request) Successful in 8s
2d5571c375
- cappedBuffer: flag truncation when a write is dropped because the cap
  was already full (an exact fill in an earlier write left no room to
  straddle the boundary), so the truncation note always appears when
  output is discarded.
- execute: clamp the requested timeout in seconds before converting to
  time.Duration, so a huge int cannot overflow and wrap negative into an
  already-expired context that kills the command immediately.
- harness: drop the write-only bufferedText buffer; answer-text deltas
  were never read from it — the round's final event carries the whole
  answer, so the buffer and its resets were dead state. Comments now
  describe the actual mechanism.
- README: document that execute inherits the harness's full process
  environment (provider keys, tokens) under the trusted-ACP posture.

Regression tests for the truncation note and the timeout clamp, plus
updated e2e comments. go test -race and golangci-lint run are clean.
sam merged commit 99487ebdfa into main 2026-10-18 15:19:50 +00:00
sam deleted branch feat/relay-streamed-reasoning 2026-10-18 15:19:51 +00:00
Sign in to join this conversation.
No reviewers
No labels
code-review
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sam/brainless!35
No description provided.