You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browse filesBrowse the repository at this point in the historyBrowse files
Yogthos
committed
fix(agent_loop): post-phase-5 code review — R1 drain collision, R3 signal threading, #2 provider name
Three fixes from the phase-4.6/phase-5 code review.
**R1**: `prepare_next_turn_from_plugin_manager` was draining
`harness-next-model` alongside `harness-next-thinking-level`.
The model slot has pre-existing dirge semantics — read by the
UI at end-of-run (`ui/mod.rs:2359`) to spawn a fresh agent
against the new model. With the prepareNextTurn hook draining
it first, the UI's consumer saw None and `harness/set-next-model`
silently failed.
Fix: only drain the thinking-level slot in the hook. The model
slot stays for the UI consumer. Mid-run model swap isn't
supported anyway (run.rs already logs a warning when
TurnUpdate.model is set — code review #3); a separate API for
real mid-run model swap waits on rig API growth.
**R3**: `opts.signal` in StreamOptions was silently ignored by
the rig stream adapter. Mid-stream cancellation against the
rig request had no effect — signal only took effect at the
next turn boundary. (Old runner.rs path had the same
limitation; not a regression but a real gap.)
Fix: thread `Option<AbortSignal>` into wrap_streamed_assistant.
Per-chunk pre-poll check: if signal is cancelled, emit an
Error event with "aborted" substring and exit. Mid-LLM-call
cancel now actually stops the rig request promptly.
**#2**: `get_api_key` hook was called with `""` instead of the
provider name. Pi contract: `getApiKey(provider: string) =>
key`. Provider-aware hooks couldn't dispatch.
Fix: add `provider_name: Option<String>` to LoopConfig (and
LoopSpawnConfig, threaded through). `AnyAgent::provider_name()`
returns the canonical name per variant ("anthropic", "glm",
etc.). spawn_runner sets it. stream_assistant_response passes
it to the hook.
**Tests** (3 new):
- prepare_next_turn_does_not_drain_next_model_slot (R1)
- signal_cancels_stream_mid_flight (R3)
- signal_none_does_not_affect_stream (R3 negative case)
- test_get_api_key_receives_provider_name (#2)
**Not fixed in this commit** (documented as deferred):
- R2: opts.api_key silently ignored by rig adapter (rig's
client carries the key at construction; per-request
override would need a rig API change)
- R4: opts.request_timeout silently ignored (same reason)
- Per-provider reasoning mappers (separate larger commit)
Gates:
- cargo build (default) clean
- cargo build --features plugin clean
- cargo build --all-features clean
- cargo test 849 passed; 6 ignored
- cargo fmt clean
0 commit comments