feat: Paseo reasoning — separate thinking block + mode-only control #14

Merged
sam merged 3 commits from rebel-duck into main 2026-09-26 13:06:17 +00:00
Collaborator

Two related changes to how reasoning is relayed and controlled in Paseo, in the sam/brainless ACP agent.

1. Stream reasoning as a separate thinking block (fix)

When a reasoning model (e.g. melious deepseek-v4-flash-0731 at a non-zero effort) replies, the thinking was shown inline with the answer instead of as a distinct Thinking block.

Root cause: eventText concatenated all text parts of the final ADK response event, including parts flagged Thought: true, into the answer, which it streamed as a single agent_message_chunk.

Fix: eventText excludes Thought parts; new eventThought collects them; the ACP path relays reasoning as a separate agent_thought_chunk update (acp.UpdateAgentThoughtText) and the answer as the regular agent_message_chunk. The single-shot stdout path prints reasoning to stderr. replayHistory separates stored reasoning the same way. Test: TestACPPromptSeparatesReasoningFromAnswer.

2. Control reasoning through session modes only (feature)

Reasoning was exposed two redundant ways: a raw thinking config option (shown as "Thinking Mode") and ACP session modes ("Change Mode", fast/normal/deep). It is now mode-only:

  • The thinking config option is dropped; the model selector is the only config option, so Paseo shows Change Mode but no raw effort selector.
  • normal is renamed to default. It previously resolved to the model's lowest (first-declared) effort, which for an [off, low, high] model silently disabled reasoning. default now turns reasoning on with no effort override — the ADK's dynamic-thinking-budget sentinel sends reasoning with no effort, so the provider applies the model's natural default. This is the same as passing reasoning: true without a reasoningEffort to the OpenAI API; no config knob is involved.
  • The mode selector is only advertised for models with a reasoning effort other than off/none, so a non-reasoning model (or one that only supports off) shows no selector.

Behavior change

For your config (deepseek-v4-flash-0731, deepseek-v4.1-flash, glm-5.3-flash, all [off, low, high]):

Mode wire effort
Fast off (reasoning disabled)
Default none sent — model uses its natural default effort
Deep high (maximum declared)

Verification

  • go build, go test ./..., golangci-lint run ./... clean.
  • racedetector test clean.
  • New/updated tests: reasoning/thought separation, mode-only config options, Default mode leaves effort unset (dynamic budget), selector hidden for non-reasoning and only-off models, mode-preset recompute across model switch.
Two related changes to how reasoning is relayed and controlled in Paseo, in the `sam/brainless` ACP agent. ## 1. Stream reasoning as a separate thinking block (fix) When a reasoning model (e.g. melious `deepseek-v4-flash-0731` at a non-zero effort) replies, the thinking was shown **inline with the answer** instead of as a distinct Thinking block. Root cause: `eventText` concatenated **all** text parts of the final ADK response event, including parts flagged `Thought: true`, into the answer, which it streamed as a single `agent_message_chunk`. Fix: `eventText` excludes `Thought` parts; new `eventThought` collects them; the ACP path relays reasoning as a separate `agent_thought_chunk` update (`acp.UpdateAgentThoughtText`) and the answer as the regular `agent_message_chunk`. The single-shot stdout path prints reasoning to stderr. `replayHistory` separates stored reasoning the same way. Test: `TestACPPromptSeparatesReasoningFromAnswer`. ## 2. Control reasoning through session modes only (feature) Reasoning was exposed two redundant ways: a raw `thinking` config option (shown as "Thinking Mode") and ACP session modes ("Change Mode", fast/normal/deep). It is now **mode-only**: - The `thinking` config option is dropped; the model selector is the only config option, so Paseo shows Change Mode but no raw effort selector. - `normal` is renamed to **default**. It previously resolved to the model's *lowest* (first-declared) effort, which for an `[off, low, high]` model silently disabled reasoning. `default` now turns reasoning **on with no effort override** — the ADK's dynamic-thinking-budget sentinel sends `reasoning` with no `effort`, so the provider applies the model's natural default. This is the same as passing `reasoning: true` without a `reasoningEffort` to the OpenAI API; no config knob is involved. - The mode selector is only advertised for models with a reasoning effort other than `off`/`none`, so a non-reasoning model (or one that only supports `off`) shows no selector. ## Behavior change For your config (`deepseek-v4-flash-0731`, `deepseek-v4.1-flash`, `glm-5.3-flash`, all `[off, low, high]`): | Mode | wire effort | |------|-------------| | Fast | off (reasoning disabled) | | Default | none sent — model uses its natural default effort | | Deep | high (maximum declared) | ## Verification - `go build`, `go test ./...`, `golangci-lint run ./...` clean. - `racedetector test` clean. - New/updated tests: reasoning/thought separation, mode-only config options, Default mode leaves effort unset (dynamic budget), selector hidden for non-reasoning and only-`off` models, mode-preset recompute across model switch.
Reasoning models emit their thinking as text parts flagged Thought in the
final ADK response event. eventText concatenated those parts into the
answer text, so Paseo rendered the thinking inline with the reply instead
of as a distinct thinking block.

Split reasoning from the answer: eventText now excludes Thought parts and
eventThought collects them, and the ACP path relays reasoning as an
agent_thought_chunk update while the answer stays an agent_message_chunk.
The single-shot stdout path prints reasoning to stderr so stdout remains a
clean answer. Replay of stored sessions separates reasoning the same way.
Reasoning was exposed two overlapping ways: a raw 'thinking' config
option (Thought Mode) listing the model's efforts, and ACP session modes
(fast/normal/deep). Showing both is redundant. Reasoning is now
mode-only, and modes are only advertised for models that meaningfully
reason.

- Drop the 'thinking' config option; the model selector is the only
  config option, so Paseo shows Change Mode but no raw effort selector.
- Rename the normal mode to default. It previously resolved to the
  model's lowest (first-declared) effort, which for an [off, low, high]
  model silently disabled reasoning. Default now maps to the model's
  declared default effort: a new optional defaultReasoningEffort config
  field, falling back to the model's lowest non-off effort. xhigh/max
  still clamp to high via the existing effort normalization.
- Hide the mode selector for models with no reasoning effort, or only
  off/none, so the client never shows a selector that does nothing.

Validate defaultReasoningEffort at config load (recognized and among the
declared efforts).
pi-agent changed title from fix: stream reasoning as a separate thinking block to feat: Paseo reasoning — separate thinking block + mode-only control 2026-09-26 12:31:52 +00:00
pi-agent force-pushed rebel-duck from 2fb4b306f5 to 9cf874fafc
All checks were successful
code-review / Agent review (pull_request) Successful in 10s
2026-09-26 12:43:02 +00:00
Compare
pi-agent left a comment

Review of PR #14 — Paseo reasoning separation + mode-only control

⚠️ Identity note: this review is posted as the PR author (pi-agent), so Forgejo forces state COMMENT instead of REQUEST_CHANGES. The findings below are genuine and should be treated as change-requesting regardless.

Reviewed with the samber/cc-skills-golang skills (code-style, naming, documentation, error-handling, safety, concurrency, security, dependency-management, testing, performance, observability, modernize) against a fresh checkout of rebel-duck (9cf874f). Verified in this session: go build ./..., go vet ./..., go test ./..., racedetector test ./internal/harness/, golangci-lint run ./internal/harness/... all clean; go doc confirms genai.Part.Thought, session.Event.IsFinalResponse, acp.UpdateAgentThoughtText, and the openaimodel bridge (dynamicThinkingBudget = -1, reasoning items surfaced as Thought:true parts) all exist exactly as the code assumes. The reasoning-separation fix is sound and the dynamic-budget semantics of Default mode are correct.

No 🔴 BLOCKING issues. Two 🟠 IMPORTANT correctness gaps in the mode/effort wiring (each requires a non-standard model config to manifest), and one 🟡 SUGGESTION. Both IMPORTANT items were reproduced empirically with scratch tests in the package (evidence quoted inline).

## Review of PR #14 — Paseo reasoning separation + mode-only control > ⚠️ **Identity note:** this review is posted as the PR author (`pi-agent`), so Forgejo forces state `COMMENT` instead of `REQUEST_CHANGES`. The findings below are genuine and should be treated as change-requesting regardless. Reviewed with the samber/cc-skills-golang skills (code-style, naming, documentation, error-handling, safety, concurrency, security, dependency-management, testing, performance, observability, modernize) against a fresh checkout of `rebel-duck` (9cf874f). Verified in this session: `go build ./...`, `go vet ./...`, `go test ./...`, `racedetector test ./internal/harness/`, `golangci-lint run ./internal/harness/...` all clean; `go doc` confirms `genai.Part.Thought`, `session.Event.IsFinalResponse`, `acp.UpdateAgentThoughtText`, and the openaimodel bridge (`dynamicThinkingBudget = -1`, reasoning items surfaced as `Thought:true` parts) all exist exactly as the code assumes. The reasoning-separation fix is sound and the dynamic-budget semantics of Default mode are correct. No 🔴 BLOCKING issues. Two 🟠 IMPORTANT correctness gaps in the mode/effort wiring (each requires a non-standard model config to manifest), and one 🟡 SUGGESTION. Both IMPORTANT items were reproduced empirically with scratch tests in the package (evidence quoted inline).
Author
Collaborator

🟠 IMPORTANT — SetSessionMode does not guard named-effort presets against the active model's declared efforts, unlike SetSessionConfigOption below it.

Setting Fast on a model whose ReasoningEffort does not include off (e.g. [low, high]) stores thinking="off", and thinkingConfig maps it to ThinkingBudget 0, which the openaimodel bridge turns into reasoning.effort="none" — a level the model never declared. The mode selector is advertised for a [low, high] model (low/high are not off/none, so HasReasoningSelector returns true), so a client can pick Fast and the harness will send an effort the model does not support (provider 400 or silent behavior change).

Reproduced: scratch test on a [low, high] model → Fast on [low,high] model: thinking="off" wire ThinkingConfig=&{...ThinkingBudget:0x...} (budget 0 → effort none).

Note the asymmetry: SetSessionConfigOption guards this exact case (if mode != modeDefault && !slices.Contains(...) { thinking = ""; mode = modeDefault }) and falls back to default. SetSessionMode has no such guard.

Fix: in SetSessionMode, after computing modeThinking, if the mode is a named-effort preset (fast→off, deep→max) that the active model does not declare, fall back to default mode — mirror the slices.Contains guard from SetSessionConfigOption.

🟠 **IMPORTANT** — `SetSessionMode` does not guard named-effort presets against the active model's declared efforts, unlike `SetSessionConfigOption` below it. Setting **Fast** on a model whose `ReasoningEffort` does not include `off` (e.g. `[low, high]`) stores `thinking="off"`, and `thinkingConfig` maps it to `ThinkingBudget 0`, which the openaimodel bridge turns into `reasoning.effort="none"` — a level the model never declared. The mode selector *is* advertised for a `[low, high]` model (`low`/`high` are not `off`/`none`, so `HasReasoningSelector` returns true), so a client can pick Fast and the harness will send an effort the model does not support (provider 400 or silent behavior change). Reproduced: scratch test on a `[low, high]` model → `Fast on [low,high] model: thinking="off" wire ThinkingConfig=&{...ThinkingBudget:0x...}` (budget 0 → effort `none`). Note the asymmetry: `SetSessionConfigOption` guards this exact case (`if mode != modeDefault && !slices.Contains(...) { thinking = ""; mode = modeDefault }`) and falls back to default. `SetSessionMode` has no such guard. **Fix:** in `SetSessionMode`, after computing `modeThinking`, if the mode is a named-effort preset (fast→off, deep→max) that the active model does not declare, fall back to default mode — mirror the `slices.Contains` guard from `SetSessionConfigOption`.
@ -263,0 +279,4 @@
// reasoning with no effort, so the provider applies the model's natural
// default effort. This is what the "default" mode means — reasoning on, no
// override.
const dynamicThinkingBudget = -1
Author
Collaborator

🟡 SUGGESTION — dynamicThinkingBudget = -1 is a magic constant duplicated from the ADK openaimodel bridge's private sentinel (same literal -1 in google.golang.org/adk/v2@v2.4.0/model/openaimodel/request.go). If the bridge ever changes that sentinel, Default-mode reasoning silently changes meaning. The doc comment already points at the bridge, which mitigates it; a cheap hardening is a test asserting that thinkingConfig(efforts, "") returns ThinkingBudget == -1 (pinning the coupling). Minor, optional.

🟡 **SUGGESTION** — `dynamicThinkingBudget = -1` is a magic constant duplicated from the ADK openaimodel bridge's private sentinel (same literal `-1` in `google.golang.org/adk/v2@v2.4.0/model/openaimodel/request.go`). If the bridge ever changes that sentinel, Default-mode reasoning silently changes meaning. The doc comment already points at the bridge, which mitigates it; a cheap hardening is a test asserting that `thinkingConfig(efforts, "")` returns `ThinkingBudget == -1` (pinning the coupling). Minor, optional.
@ -295,2 +313,3 @@
default:
return nil // unknown level: defer to the model
// No specific level: reasoning on, effort left to the model's default.
budget := int32(dynamicThinkingBudget)
Author
Collaborator

🟠 IMPORTANT — Default mode turns reasoning on for an off/none-only model, contradicting both the pre-PR behavior and the harness's own HasReasoningSelector.

For a model declaring only [off] (or [none]), len(efforts) > 0 so this default: branch is reached and returns ThinkingBudget = -1 (dynamic budget). The bridge sends no reasoning.effort, so the model reasons at its natural default. But HasReasoningSelector treats such a model as non-reasoning (selector hidden, "cannot honor any preset"), and the pre-PR code resolved an unset level to efforts[0] = off → effort none. So a configured off-only model now silently reasons, with no selector for the user to correct it.

Reproduced: scratch test on a [off]-only model → default mode on off-only model: thinking="" -> reasoning block budget=-1 (dynamic → reasoning on), while modeState hides the selector.

The root inconsistency is that Reasoning() (len>0) and HasReasoningSelector() (has an effort other than off/none) disagree for off/none-only models, and the wire path trusts Reasoning().

Fix: map the unset/default level to effort none (budget 0) when the model has no meaningful effort — i.e. guard the dynamic budget on HasReasoningSelector rather than just len(efforts) == 0.

🟠 **IMPORTANT** — Default mode turns reasoning **on** for an off/none-only model, contradicting both the pre-PR behavior and the harness's own `HasReasoningSelector`. For a model declaring only `[off]` (or `[none]`), `len(efforts) > 0` so this `default:` branch is reached and returns `ThinkingBudget = -1` (dynamic budget). The bridge sends no `reasoning.effort`, so the model reasons at its natural default. But `HasReasoningSelector` treats such a model as non-reasoning (selector hidden, "cannot honor any preset"), and the pre-PR code resolved an unset level to `efforts[0]` = `off` → effort `none`. So a configured off-only model now silently reasons, with no selector for the user to correct it. Reproduced: scratch test on a `[off]`-only model → `default mode on off-only model: thinking="" -> reasoning block budget=-1` (dynamic → reasoning on), while `modeState` hides the selector. The root inconsistency is that `Reasoning()` (len>0) and `HasReasoningSelector()` (has an effort other than off/none) disagree for off/none-only models, and the wire path trusts `Reasoning()`. **Fix:** map the unset/default level to effort `none` (budget 0) when the model has no meaningful effort — i.e. guard the dynamic budget on `HasReasoningSelector` rather than just `len(efforts) == 0`.
Address two correctness gaps found in review of the mode-only reasoning
control:

- SetSessionMode did not guard named-effort presets (fast->off,
  deep->max) against the active model's declared efforts. Fast on a
  [low, high] model stored thinking=off, which the ADK bridge sends as
  reasoning.effort=none — a level the model never declared (provider 400
  or silent behavior change). SetSessionMode now mirrors the
  slices.Contains guard in SetSessionConfigOption and falls back to
  default mode when a preset names an undeclared effort.

- The default mode turned reasoning on for a model whose only declared
  efforts are off/none, contradicting the hidden mode selector: an
  off-only model silently reasoned at its natural default with no way to
  correct it. thinkingConfig now gates the dynamic-budget (reasoning on,
  model's own effort) on a meaningful reasoning effort (anything other
  than off/none), leaving an off-only model with no reasoning, matching
  HasReasoningSelector.
Author
Collaborator

Resolved in commit 0870d6b (force-pushed to rebel-duck).

🟠 Comment 567 (SetSessionMode undeclared preset): Fixed. SetSessionMode now mirrors the slices.Contains guard from SetSessionConfigOption: a named-effort preset (fast→off, deep→max) that the active model does not declare falls back to default mode instead of putting an undeclared effort on the wire. Test: TestSetSessionModeFallsBackForUndeclaredPreset. The e2e mode test's model now declares off ([off, low, high]) so Fast→none is still exercised.

🟠 Comment 568 (default mode turns reasoning on for off/none-only models): Fixed. Added meaningfulReasoning(efforts) (shared with HasReasoningSelector); thinkingConfig now returns nil (no reasoning) for the unset/default level on a model whose only declared efforts are off/none, so such a model never silently reasons — consistent with the hidden mode selector. Test: TestOffOnlyModelDefaultLeavesReasoningOff.

🟡 Comment 569 (pin the dynamic-budget sentinel): Already covered — TestSelectorModelDefaultThinkingWhenUnset asserts *ThinkingBudget == dynamicThinkingBudget (-1), pinning the coupling to the ADK bridge's sentinel.

Verification: go build, go test ./... (x3), golangci-lint run ./..., racedetector test all clean.

Resolved in commit `0870d6b` (force-pushed to `rebel-duck`). **🟠 Comment 567 (SetSessionMode undeclared preset):** Fixed. `SetSessionMode` now mirrors the `slices.Contains` guard from `SetSessionConfigOption`: a named-effort preset (fast→off, deep→max) that the active model does not declare falls back to `default` mode instead of putting an undeclared effort on the wire. Test: `TestSetSessionModeFallsBackForUndeclaredPreset`. The e2e mode test's model now declares `off` (`[off, low, high]`) so Fast→none is still exercised. **🟠 Comment 568 (default mode turns reasoning on for off/none-only models):** Fixed. Added `meaningfulReasoning(efforts)` (shared with `HasReasoningSelector`); `thinkingConfig` now returns `nil` (no reasoning) for the unset/default level on a model whose only declared efforts are off/none, so such a model never silently reasons — consistent with the hidden mode selector. Test: `TestOffOnlyModelDefaultLeavesReasoningOff`. **🟡 Comment 569 (pin the dynamic-budget sentinel):** Already covered — `TestSelectorModelDefaultThinkingWhenUnset` asserts `*ThinkingBudget == dynamicThinkingBudget` (-1), pinning the coupling to the ADK bridge's sentinel. Verification: `go build`, `go test ./...` (x3), `golangci-lint run ./...`, `racedetector test` all clean.
sam merged commit ae7ad83f91 into main 2026-09-26 13:06:17 +00:00
sam deleted branch rebel-duck 2026-09-26 13:06:17 +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!14
No description provided.