Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api/mcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -7677,7 +7677,7 @@ Does NOT throw when:

> **parseCodexTokenUsage**(`stdout`): [`CodexTokenUsage`](#codextokenusage)

Defined in: [mcp/local-harness.ts:1341](https://github.com/tangle-network/agent-runtime/blob/main/src/mcp/local-harness.ts#L1341)
Defined in: [mcp/local-harness.ts:1348](https://github.com/tangle-network/agent-runtime/blob/main/src/mcp/local-harness.ts#L1348)

Parse and validate the one terminal usage event emitted by `codex exec --json`.

Expand Down
9 changes: 8 additions & 1 deletion src/mcp/local-harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,14 @@ export async function runLocalHarness(
: buildHarnessArgs(harness, taskPrompt, options)
if (options.codexReproducible) assertCodexReproducibleInvocation(requestedCommand, args)

const baseEnv = options.env ?? process.env
// We spawn the harness with `cwd`, but a harness that resolves its working
// directory from `$PWD` rather than `getcwd()` (opencode does; the others may)
// inherits the parent's stale `PWD` and edits the WRONG directory — its
// worktree diff then comes back empty and the delegation fails with a phantom
// "empty patch". Pin `PWD` to `cwd` so the harness edits where it was placed.
// `baseEnv` feeds both the codex-isolated and the plain spawn paths below, so
// pinning it here covers every runLocalHarness consumer.
const baseEnv: NodeJS.ProcessEnv = { ...(options.env ?? process.env), PWD: cwd }
const isolated = options.codexReproducible
? await isolateCodexHome({
baseEnv,
Expand Down
Loading