fix(droid): harden the codec against live droid 0.164.0 behavior#97
Merged
Conversation
Live-probed Factory droid 0.164.0 (the CLI self-updates; 0.153.1 was the last verified engine) and fixed three seams that had drifted: - stream-json is droid-NATIVE, not the Anthropic agent-SDK envelope: map system/message/reasoning/tool_call/tool_result/completion lines with a custom StreamEventExtractor (sdkStreamExtractor yielded only `session`, so live streaming/token estimation saw nothing). - the field extractor is now line-type aware: it no longer salvages the echoed user prompt or reasoning text as result text on a truncated stream, and it reads the closing completion line's `finalText`. - session continuity via `--fork <id>`: on 0.164.0, `exec -s <id>` fetches the session from Factory's backend and fails for locally created exec sessions (silent exit 1; "Failed to fetch session" lands only in ~/.factory/logs) — every continuation turn would crash-loop. `--fork` loads the local transcript and continues under a fresh id (verified live: cross-turn recall works); goaly already threads whatever id each run reports, so continuity is a fork chain. - interactive resume hint: `droid --resume <id>` (the documented top-level flag; `--session-id` exists only on `exec`). Verified live end-to-end: a two-turn AgentCliHarness probe (streaming events + fork memory recall) and a full goaly run with --harness droid --llm-provider droid to DONE (both keys turned; usage reported). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011H2PtexDeeD3JkGTVQPycg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The droid codec was verified against droid 0.153.1; the CLI self-updates and the engine now running is 0.164.0, where three of the codec's assumptions no longer hold. Every finding below was probed live against the installed binary (throwaway git sandbox, trivial prompts).
Discovery worksheet (live, droid 0.164.0)
What changed
sdkStreamExtractor, which produced only a lonesessionevent → dead live view and no issue-enhance: complete & robust token accounting (meter LLM steps; estimate from streamed turns when self-report is missing) #24 token estimation).texton the user prompt echo and reasoning lines, so the old flat mapping could return the caller's own prompt as a "completed" result on a truncated stream. Now only assistant messages and the closingcompletionline (finalText) bear result text; a stream cut after the echo correctly classifiestruncated.--fork <id>instead of--session-id <id>:-scrash-loops every continuation turn on 0.164.0 (the orchestrator re-threads the failed id,step.ts:467). Fork-chaining keeps real conversation memory; goaly never assumed session-id stability.interactiveResume→droid --resume <id>(documented top-level flag;--session-idexists only onexec). Note: droid's top level silently ignores unknown flags, so the old hint would boot a fresh interactive session without complaint.docs/adding-a-harness.md(droid no longer an example of the flat/SDK reuse),README.mdresume-cmd example,output.ts/stream.tsdoc comments.Live verification
AgentCliHarnessprobe against the real binary: turn 1 streamed (session/message/usage/donethrough the new extractor,tokenSource: 'reported'), turn 2 fork-resumed turn 1's session and recalled the codeword.goalyd run --goal ... --verify-cmd ... --harness droid --llm-provider droid --autonomous→ DONE in 1 iteration, deterministic rung green + droid Sign-off approver, spend report with per-category breakdown, banner printsdroid --resume <id>.Tests
npm run typecheck: clean for all touched files. Pre-existing failures insrc/telemetry/telemetry.test.ts(5 tests + typecheck errors) exist onorigin/mainand are untouched here — the test file expects a different telemetry API than the committed module.npx vitest runon the 7 affected files: 122/122 green; full suite: 1709 passed, 5 failed (the pre-existing telemetry ones only).--forkargv (fresh/resume/model/streaming), native-envelope streaming throughAgentCliHarness.🤖 Generated with Claude Code
https://claude.ai/code/session_011H2PtexDeeD3JkGTVQPycg