refactor(agent-core-v2): drop the llm state machine, let turn invoke the request actor directly - #3710
Conversation
…the request actor directly
|
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
commit: |
Docs-only conflicts with the protocol trait refactor (#3641), resolved to match the merged code: - design principles: keep the turn-level event wording (the llm machine is gone), take the typed per-protocol trait description with the leak boundary re-pointed at the turn - request lifecycle: the requester plan* composition, with recovery and empty-response judgment described where they live now — the turn
Resolve the overlap with the llm-machine removal (#3710): - the machine's createRequestActor is gone; the credential resolution and the abort-guarded error boundary move into llm/requester/actor.ts, kept synchronous on the credential-less path so the turn startup cascade keeps its ordering - docs/{en,zh}/llm.md: unify principles and the request lifecycle with the turn-driven orchestration — credential resolution in the request actor, the recovery strategy chain and empty-response judgment in the turn - turn.test.ts: drive the request actor through a harness machine instead of the deleted llm machine
Related Issue
No linked issue — internal cleanup discussed offline.
Problem
The llm state machine (
createLlmMachineinsrc/human/llm/requester/machine.ts) had decayed into a hollow wrapper: the turn machine'sinvokehas noonDoneso the machine'sLlmOutput/outcome was never consumed, its ownemit()calls had no subscribers (all listeners attach to the root agent actor, which re-emitsllm.*itself), retry/recovery are actually driven by the turn machine, and persistence only readssnapshot.contextwithout serializing invoked child state. Everything it did reduced to a singlefromCallbackthat forwards requester events to the parent.What changed
requester/machine.ts; keep the event contract (LlmEvent,LlmInput,MessageResolver) and the thinfromCallbackadapter asrequester/actor.ts(createRequestActor) —invoke.srcstill needs actor logic, but not a state machine.createTurnMachine(llmActor, options)→createTurnMachine(requester, options); the dormantmessageResolversextension point moves to turn options (media ref / tool-select resolvers and their tests preserved).engine.tscomposes one layer less; 8 test files updated mechanically;docs/en|zh/llm.mdprinciple 5 corrected (retry/recovery were always turn-driven) and a rejected-scheme entry added.Verified:
tsc --noEmit,check-import-boundaries,check-no-comments,oxlint --type-aware(0 errors), full agent-core-v2 suite (365 files / 6528 tests) all pass.Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.