3.7 KiB
3.7 KiB
Delegation intent: unify reasoning persistence with block lifecycle
Intent:
- Implement the
unify-reasoning-block-lifecycleticket by removing the separateReasoningItemside channel and making the reasoning/thinking block lifecycle the single authoritative path for live streaming and persistence.
Requirements:
- Start by mapping the current reasoning paths in
llm-worker: Anthropic thinking stream, OpenAI Responses reasoning items, Timeline block handlers,ReasoningItemCollector, Worker finalization, and request serialization round-trip tests. - Remove the separate finalized reasoning event path:
ReasoningItemEvent;ReasoningItemKind;ReasoningItemCollector;Timeline::on_reasoning_item/dispatch_reasoning_item/reasoning_item_handlers.
- Extend the reasoning/thinking block lifecycle so stop/finalization carries all provider material needed to build
Item::Reasoning:- text;
- reasoning item id;
- summary;
- encrypted content;
- Anthropic thinking signature;
- redacted thinking payload metadata.
- Convert Anthropic
thinking_delta/signature_delta/ redacted thinking handling to finalize through reasoning block stop metadata, without emitting a separateReasoningItemevent. - Convert OpenAI Responses completed reasoning items into reasoning block lifecycle events, including metadata-only reasoning where there is no streamed text delta.
- Update Worker collection/finalization so
Item::Reasoningis built from reasoning block lifecycle state. - Preserve live streaming thinking/reasoning callbacks for UI/trace consumers.
- Preserve persisted reasoning history round-trip behavior for Anthropic and OpenAI Responses.
- Remove misleading comments that treat reasoning as meta/single-event content.
- Do not add backward compatibility aliases or keep duplicate old/new reasoning concepts.
Invariants:
- Do not drop provider material required for reasoning round-trip (
signature, redacted thinking metadata,id,summary,encrypted_content). - Do not hide model-affecting reasoning persistence in a context-only path; persisted reasoning must remain explainable through committed history items.
- Do not redesign unrelated provider request serialization.
- Do not read ignored secret-like file contents.
- Do not edit the parent workspace; work only in the delegated worktree.
- Do not close the ticket, merge the branch, delete worktrees, or push.
Non-goals:
- No E2E spawned-process test framework.
- No product-level behavior changes beyond event model cleanup.
- No dependency changes.
- No compatibility layer for the removed
ReasoningItemevent path.
Escalate if:
- A provider requires reasoning persistence material that cannot naturally fit in block lifecycle metadata.
- OpenAI Responses reasoning items cannot be represented as synthetic block lifecycle events without losing ordering or identity semantics.
- The change requires broad public API churn outside
llm-workerand its direct consumers. - Existing tests imply a behavior conflict between live streaming callbacks and persistence.
Validation:
- Run focused reasoning/timeline/provider tests that cover Anthropic thinking signature/redacted material and OpenAI Responses
id/summary/encrypted_contentround-trip. - Run
cargo test -p llm-worker --lib. - Run
cargo check --workspace --all-targets. - Run
./tickets.sh doctorandgit diff --check. - Run
nix build .#yoiif feasible; record if skipped and why. - Commit the implementation in the worktree when reviewable.
Completion report:
- investigation summary;
- implementation summary;
- changed files;
- commit hash(es);
- validation commands and results;
- unresolved risks or parent decisions needed;
- whether ready for external review.