feat(cli): add --resume and -p flags to netclaw chat for scripted multi-turn sessions#613
Merged
Merged
Conversation
…-json support (#611) Unify the headless prompt and interactive resume code paths so scripted multi-turn conversations work. `netclaw chat -p --resume <id> "prompt"` creates-or-resumes a named session in headless mode, enabling multi-turn evals, KV cache benchmarking, and compaction regression testing. - Remove top-level `netclaw -p` — headless is now `netclaw chat -p` - Add `--resume` support to headless mode via DaemonClient.ResumeSessionAsync with configurable ChannelType (was hardcoded to TUI) - Add `--json` flag for structured output (sessionId, response, toolCalls, usage) - Add multi-turn + JSON smoke tests to scripts/smoke/check.sh - Update evals, docs, and README references from `netclaw -p` to `netclaw chat -p`
The deferred logWriter captured in R3 subscription closures lacked a memory barrier between the assigning thread and the callback thread. Use Volatile.Read/Write for cross-thread visibility. Move logWriter declaration outside try and add a finally block so the writer is disposed even if an exception occurs after creation.
The eval harness now builds the Docker image and CLI binary from the current source tree before running evals, ensuring tests always reflect the branch under development rather than a stale published image. - Add build_local_image() step that calls scripts/docker/build-image.sh - Default NETCLAW_IMAGE to :dev (locally built) and NETCLAW_BIN to ./publish/cli/netclaw - Add NETCLAW_EVAL_NO_BUILD=1 to skip build for repeated runs - Add evals/quick-multi-turn-test.sh: standalone 2-turn resume test that validates context carryover and --json output in an isolated container
This was referenced Apr 12, 2026
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
Resolves #611. Unifies the headless prompt and interactive resume code paths so scripted multi-turn conversations work end-to-end.
-punderchatsubcommand —netclaw chat -p "prompt"replaces the top-levelnetclaw -p. The old form is removed (returns "not a netclaw command").--resumein headless mode —netclaw chat -p --resume <id> "prompt"creates-or-resumes a named session, enabling multi-turn evals, KV cache benchmarking, and compaction regression testing.--jsonoutput —netclaw chat -p --json "prompt"emits structured JSON (sessionId,response,toolCalls,usage) for machine consumption.evals/run-evals.shnow runsscripts/docker/build-image.shbefore evals so tests always reflect the current branch.NETCLAW_EVAL_NO_BUILD=1skips for repeated runs.evals/quick-multi-turn-test.shvalidates context carryover and JSON output in an isolated Docker container.Key changes
CliArgsParser.csHeadless/MissingPromptArgenum values;-pis no longer a top-level commandDaemonClient.csResumeSessionAsyncacceptsChannelType(was hardcoded to TUI)HeadlessOptions.csPrompt,ResumeSessionId,JsonOutputHeadlessChannel.csVolatile.Read/WriteProgram.cs-p/--json/positional prompt,HeadlessOptionsregistration, updated help textevals/run-evals.shbuild_local_image()step, defaults to locally-built:devimage +./publish/cli/netclawevals/quick-multi-turn-test.shTest plan
dotnet build— all projects compiledotnet test— 413 CLI tests pass (updatedCliArgsParserTests,DaemonClientSessionTests)netclaw chat -p "hello"— headless single promptnetclaw chat -p --resume <id> "hello"+ follow-up turn — context carryover verifiednetclaw chat -p --json "hello"— JSON output withsessionIdfieldevals/quick-multi-turn-test.sh— 5/5 assertions pass in isolated Docker containernetclaw -p "hello"— correctly returns "not a netclaw command" (intentional removal)