Skip to content

feat(cli): add --resume and -p flags to netclaw chat for scripted multi-turn sessions#613

Merged
Aaronontheweb merged 3 commits into
devfrom
claude-wt-netclaw-chat-changes
Apr 12, 2026
Merged

feat(cli): add --resume and -p flags to netclaw chat for scripted multi-turn sessions#613
Aaronontheweb merged 3 commits into
devfrom
claude-wt-netclaw-chat-changes

Conversation

@Aaronontheweb

Copy link
Copy Markdown
Collaborator

Summary

Resolves #611. Unifies the headless prompt and interactive resume code paths so scripted multi-turn conversations work end-to-end.

  • Move -p under chat subcommandnetclaw chat -p "prompt" replaces the top-level netclaw -p. The old form is removed (returns "not a netclaw command").
  • --resume in headless modenetclaw chat -p --resume <id> "prompt" creates-or-resumes a named session, enabling multi-turn evals, KV cache benchmarking, and compaction regression testing.
  • --json outputnetclaw chat -p --json "prompt" emits structured JSON (sessionId, response, toolCalls, usage) for machine consumption.
  • Eval harness builds from sourceevals/run-evals.sh now runs scripts/docker/build-image.sh before evals so tests always reflect the current branch. NETCLAW_EVAL_NO_BUILD=1 skips for repeated runs.
  • Multi-turn verification testevals/quick-multi-turn-test.sh validates context carryover and JSON output in an isolated Docker container.

Key changes

File Change
CliArgsParser.cs Remove Headless/MissingPromptArg enum values; -p is no longer a top-level command
DaemonClient.cs ResumeSessionAsync accepts ChannelType (was hardcoded to TUI)
HeadlessOptions.cs New record: Prompt, ResumeSessionId, JsonOutput
HeadlessChannel.cs Resume support, JSON output accumulation, thread-safe deferred logWriter with Volatile.Read/Write
Program.cs Chat arg parsing for -p/--json/positional prompt, HeadlessOptions registration, updated help text
evals/run-evals.sh build_local_image() step, defaults to locally-built :dev image + ./publish/cli/netclaw
evals/quick-multi-turn-test.sh Standalone 2-turn resume + JSON verification against isolated container

Test plan

  • dotnet build — all projects compile
  • dotnet test — 413 CLI tests pass (updated CliArgsParserTests, DaemonClientSessionTests)
  • netclaw chat -p "hello" — headless single prompt
  • netclaw chat -p --resume <id> "hello" + follow-up turn — context carryover verified
  • netclaw chat -p --json "hello" — JSON output with sessionId field
  • evals/quick-multi-turn-test.sh — 5/5 assertions pass in isolated Docker container
  • netclaw -p "hello" — correctly returns "not a netclaw command" (intentional removal)

…-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
@Aaronontheweb Aaronontheweb merged commit 035e559 into dev Apr 12, 2026
4 checks passed
@Aaronontheweb Aaronontheweb deleted the claude-wt-netclaw-chat-changes branch April 12, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(cli): add --resume and -p flags to netclaw chat for scripted multi-turn sessions

1 participant