feat: add configuration for model, mode, and thought level#205
Merged
NathanFlurry merged 9 commits intomainfrom Mar 6, 2026
Merged
feat: add configuration for model, mode, and thought level#205NathanFlurry merged 9 commits intomainfrom
NathanFlurry merged 9 commits intomainfrom
Conversation
Use `.first()` with safe fallback instead of direct `[0]` index access, which would panic if the Vec is empty and no default is set. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- destroySession: wrap session/cancel RPC in try/catch so local cleanup always succeeds even when the agent is unreachable - createSession/resumeOrCreateSession: clean up the remote session if post-creation config calls (setMode/setModel/setThoughtLevel) fail, preventing leaked orphan sessions - cli.mdx: fix example output to match current claude.json (model name, model order, and populated modes) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- resumeOrCreateSession: Remove destroy-on-error for the resume path. Config errors now propagate without destroying a pre-existing session. The destroy pattern remains in createSession (where the session is newly created and has no prior state to preserve). - setSessionMode fallback: When session/set_mode returns -32601 and the fallback uses session/set_config_option, now keep modes.currentModeId in sync with the updated currentValue. Prevents stale cached state in getModes() when the fallback path is used. - persistSessionStateFromMethod: Re-read the record from persistence instead of using a stale pre-await snapshot. Prevents race conditions where concurrent session/update events (processed by persistSessionStateFromEvent) are silently overwritten by optimistic updates. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
|
🚅 Deployed to the sandbox-agent-pr-205 environment in sandbox-agent
|
…I list
- Replace invalid Codex mode values ("plan", "build") with valid ones
("auto", "full-access") in agent-sessions.mdx and sdk-overview.mdx
- Update CLAUDE.md stable method enumerations to include new session
config methods (setSessionMode, setSessionModel, etc.)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Keep both session config utility functions (effort-level) and process log SSE / WebSocket helpers (main). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…sistence race Add summary/description to all process management endpoint specs and the not_found error type. Fix hydrateSessionConfigOptions to re-read from persistence after the network call, and sync mode-category configOptions on session/update current_mode_update events. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
# Conflicts: # sdks/typescript/src/client.ts
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.
This PR adds end-to-end model/mode/thought-level configuration support across the Sandbox Agent TypeScript SDK, server routing/CLI reporting, and integration tests. It updates agent capability fallback/config extraction and agent config resources so report output includes normalized categories and defaults where available. It also updates docs for sessions/SDK/CLI and the new agent capabilities reference, including Claude-specific effort-level guidance via filesystem configuration before session creation. The branch includes related install/agent-management wiring and supporting type/export updates needed for the new configuration flows.
Bug Fixes Included
This PR also includes three critical bug fixes for the session configuration logic:
1. Session Lifecycle: Prevent Destruction of Pre-existing Sessions
Issue:
resumeOrCreateSessionwould destroy a pre-existing session if configuration (model/mode/thoughtLevel) failed, causing data loss.Fix: Removed the try-catch destroy block from the resume path. Config errors now propagate without destroying the session. The destroy-on-error pattern remains only in
createSession, where destroying a brand-new session on config failure is appropriate.2. Config Persistence: Sync Modes State in Fallback Path
Issue: When
setSessionModefallback usedsession/set_config_optionto set mode,persistSessionStateFromMethodonly updatedconfigOptionsbut notmodes.currentModeId, leaving the SDK's cached state inconsistent.Fix: Added logic to detect when a mode-category config option is updated via the fallback path and keep
modes.currentModeIdin sync with the new value.3. Race Condition: Fix Stale Record Overwrites
Issue:
persistSessionStateFromMethodwas called with a pre-await session record snapshot. If concurrentsession/updateevents arrived during the RPC call and updated the persisted state viapersistSessionStateFromEvent, those updates were silently overwritten by the stale snapshot.Fix: Changed
persistSessionStateFromMethodto takesessionIdand re-read the record from persistence, ensuring it always merges against the latest state rather than a stale pre-call snapshot.