Repository navigation
Restore compatibility with current Codex and Claude Code - #1
Merged
Merged
Conversation
… spawns When stoneforge runs from inside a Claude Code session (any user invoking sf from the bash tool, or a director running in Claude Code), the spawned claude subprocess inherits CLAUDECODE=1 from process.env. The explicit `CLAUDECODE: '1'` in the env spread re-asserts it. Recent versions of the claude binary refuse to start when CLAUDECODE is set, emitting "Claude Code cannot be launched inside another Claude Code session" to stderr and exiting 1. The Anthropic SDK surfaces this as "Claude Code process exited with code 1", which the spawner swallows as the cryptic "Session exited before init". Strip CLAUDECODE from the inherited env before passing to the SDK (headless) and node-pty (interactive). Stoneforge IS the parent of the spawned claude; the spawned claude is a fresh top-level session, not nested. This reverses the intent of stoneforge-ai#32 for the macOS/Linux case but keeps the spawn-env construction shape that stoneforge-ai#32 fixed for Windows. If there is a Windows-specific reason CLAUDECODE must be set, gate it on platform. Refs stoneforge-ai#32 (the original Windows fix that introduced CLAUDECODE='1'). (cherry picked from commit 18c9238)
…trip tests Move the env construction (process.env merge, overrides, CLAUDECODE strip, optional STONEFORGE_ROOT) from headless.ts and interactive.ts into a shared helper at packages/smithy/src/providers/claude/env.ts. Both providers now call buildClaudeSpawnEnv() rather than duplicating the shape. Adds 7 unit tests for the helper (env.bun.test.ts) covering the CLAUDECODE strip from inherited env, the strip from caller-supplied overrides, override precedence, STONEFORGE_ROOT injection, and input non-mutation. Also adds 2 integration-style tests in headless.bun.test.ts to verify the headless provider actually invokes the helper correctly (SDK options.env reflects the strip). Refs stoneforge-ai#103. (cherry picked from commit 5b1ef3d)
(cherry picked from commit 6781b78)
Extract the Codex interactive argument construction into buildCodexInteractiveArgs so the unit test exercises the same production arg-building logic used by spawn instead of duplicating that logic in the test. The helper preserves the existing working-directory, resume, and model behavior. Codex now documents --sandbox workspace-write as the replacement for the deprecated --full-auto shortcut, so use the documented sandbox flag for fresh and resumed interactive sessions. Refs stoneforge-ai#114. (cherry picked from commit 9baf6e9)
(cherry picked from commit cc9cc15)
(cherry picked from commit f745d57)
imcitius
marked this pull request as ready for review
September 25, 2026 21:44
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.
Stoneforge's Codex integration used a removed CLI flag and outdated app-server response shapes, so startup could fail, cancellation omitted the required turn ID, and failed turns could be reported as successful. This updates startup/resume, model discovery, cancellation and error handling. Failed headless requests now release their sessions and report a non-zero exit.
Agent environment overrides, including
SF_ENTITY_IDand the workspace root, now reach each Codex thread independently, including resumed threads. Previously they were dropped by the shared app-server integration, so task commands could use the operator identity instead of the running agent.Claude Agent SDK is updated from 0.2.45 to 0.3.282. Session launches and model discovery strip the inherited nested-session marker, and closing a session terminates the SDK process and its transports. Codex resume IDs discovered during graceful shutdown are retained in session history; invalid legacy IDs are rejected.
The branch preserves authorship of fixes from stoneforge-ai#104, stoneforge-ai#116 and stoneforge-ai#118. Additional fixes, regression tests, opt-in live checks, documentation and changesets are included.
Validation:
pnpm typecheckandpnpm buildpassed after the latest changes. The new orchestration script also passes a standalone strict TypeScript check.git diff --checkpassed. These are local results; the fork currently has no GitHub Actions workflows.Live checks use model quota and require authenticated CLIs:
Limitations: interactive terminal conversations, GitHub approval workflows and Windows/Linux execution have not been tested live. The orchestration fixture covers a successful single-task local merge, not conflict resolution, rate-limit recovery or sustained concurrent workload. No release or deployment is included.