-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: isolate claude-code sessions via stream-json session_id #7108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| )] | ||
| async fn complete_with_model( | ||
| &self, | ||
| _session_id: Option<&str>, // create_session == YYYYMMDD_N, but --session-id requires a UUID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this only applies to CLI validation, not the ndjson itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates the claude-code CLI provider to use a session_id in the stream-json protocol so a single persistent subprocess can correctly isolate multiple concurrent/serial Goose sessions (and avoids leaking state between tests).
Changes:
- Add
session_idto theclaude-codestream-json input payload and remove the previousmessages_sentbookkeeping. - Update provider integration tests to support CLI providers (
claude-code,codex) and use per-test session IDs where needed. - Refactor CLI provider
from_envconstruction forclaude-codeandcodexinto theProviderDefimplementation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| crates/goose/src/providers/claude_code.rs | Add session_id to stream-json input; remove messages_sent; adjust session-id handling in complete_with_model. |
| crates/goose/src/providers/codex.rs | Move env-based provider construction into ProviderDef::from_env. |
| crates/goose/tests/providers.rs | Expand integration tests for CLI providers; introduce CLI/non-CLI session handling and skip logic. |
ed6d261 to
ff6c11a
Compare
Signed-off-by: Adrian Cole <adrian@tetrate.io>
ff6c11a to
950f9a6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
…tensions-deeplinks * 'main' of github.com:block/goose: [docs] update authors.yaml file (#7114) Implement manpage generation for goose-cli (#6980) docs: tool output optimization (#7109) Fix duplicated output in Code Mode by filtering content by audience (#7117) Enable tom (Top Of Mind) platform extension by default (#7111) chore: added notification for canary build failure (#7106) fix: fix windows bundle random failure and optimise canary build (#7105) feat(acp): add model selection support for session/new and session/set_model (#7112) fix: isolate claude-code sessions via stream-json session_id (#7108) ci: enable agentic provider live tests (claude-code, codex, gemini-cli) (#7088) docs: codex subscription support (#7104) chore: add a new scenario (#7107) fix: Goose Desktop missing Calendar and Reminders entitlements (#7100) Fix 'Edit In Place' and 'Fork Session' features (#6970) Fix: Only send command content to command injection classifier (excluding part of tool call dict) (#7082) Docs: require auth optional for custom providers (#7098) fix: improve text-muted contrast for better readability (#7095) Always sync bundled extensions (#7057)
* origin/main: feat: add AGENT=goose environment variable for cross-tool compatibility (#7017) fix: strip empty extensions array when deeplink also (#7096) [docs] update authors.yaml file (#7114) Implement manpage generation for goose-cli (#6980) docs: tool output optimization (#7109) Fix duplicated output in Code Mode by filtering content by audience (#7117) Enable tom (Top Of Mind) platform extension by default (#7111) chore: added notification for canary build failure (#7106) fix: fix windows bundle random failure and optimise canary build (#7105) feat(acp): add model selection support for session/new and session/set_model (#7112) fix: isolate claude-code sessions via stream-json session_id (#7108) ci: enable agentic provider live tests (claude-code, codex, gemini-cli) (#7088) docs: codex subscription support (#7104) chore: add a new scenario (#7107) fix: Goose Desktop missing Calendar and Reminders entitlements (#7100) Fix 'Edit In Place' and 'Fork Session' features (#6970) Fix: Only send command content to command injection classifier (excluding part of tool call dict) (#7082) # Conflicts: # crates/goose/src/agents/extension.rs
* origin/main: (30 commits) docs: GCP Vertex AI org policy filtering & update OnboardingProviderSetup component (#7125) feat: replace subagent and skills with unified summon extension (#6964) feat: add AGENT=goose environment variable for cross-tool compatibility (#7017) fix: strip empty extensions array when deeplink also (#7096) [docs] update authors.yaml file (#7114) Implement manpage generation for goose-cli (#6980) docs: tool output optimization (#7109) Fix duplicated output in Code Mode by filtering content by audience (#7117) Enable tom (Top Of Mind) platform extension by default (#7111) chore: added notification for canary build failure (#7106) fix: fix windows bundle random failure and optimise canary build (#7105) feat(acp): add model selection support for session/new and session/set_model (#7112) fix: isolate claude-code sessions via stream-json session_id (#7108) ci: enable agentic provider live tests (claude-code, codex, gemini-cli) (#7088) docs: codex subscription support (#7104) chore: add a new scenario (#7107) fix: Goose Desktop missing Calendar and Reminders entitlements (#7100) Fix 'Edit In Place' and 'Fork Session' features (#6970) Fix: Only send command content to command injection classifier (excluding part of tool call dict) (#7082) Docs: require auth optional for custom providers (#7098) ...
Summary
claude-codeshares a persistent subprocess that previously conflated all sessions into one. This caused a lot of problems, notably tests would include state from other tests. This could add pressure to restart the subprocess, rather than solve the bookkeeping problem.This implements
session_idto the stream-json protocol and removes themessages_sentbookkeeping as sessions are handled internally to claude.This is standard practice for stream-json SDKs: Each sends only the new user message per turn with a
session_idfield, and the CLI maintains conversation context internally:session_iddefaults to"default"session_iddefaults to"default"session_idon everyStreamMessageThis also updates
providers.rsintegration tests to use a unique session ID per test, and support running withclaude-codeandcodexCLI providers.Type of Change
AI Assistance
Testing
Related Issues