mirror of
https://github.com/garrytan/gstack.git
synced 2026-07-04 15:17:54 +02:00
feat: agent-sdk-runner spawns hermetic children via complete Options.env
The historical 'env: breaks SDK auth' failure was partial-env replacement: Options.env replaces the child's entire environment, so objects lacking ANTHROPIC_API_KEY killed auth. Passing the complete hermetic env (key + PATH + redirected CLAUDE_CONFIG_DIR/GSTACK_HOME) works — validated live via query() with a Bash tool call (success, real cost, Conductor vars scrubbed). Per-test opts.env merges last; ambient key mutation still works because the builder reads process.env at call time. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -347,7 +347,13 @@ describe('runAgentSdkTest — options propagation', () => {
|
||||
expect(opts.permissionMode).toBe('bypassPermissions');
|
||||
expect(opts.allowDangerouslySkipPermissions).toBe(true);
|
||||
expect(opts.settingSources).toEqual([]);
|
||||
expect(opts.env).toEqual({ ANTHROPIC_API_KEY: 'fake' });
|
||||
// env is the COMPLETE hermetic env with the per-test override merged
|
||||
// last — partial pass-through was the documented SDK auth-breaker
|
||||
// (Options.env replaces the child's entire environment).
|
||||
expect(opts.env?.ANTHROPIC_API_KEY).toBe('fake');
|
||||
expect(opts.env?.PATH).toBeTruthy();
|
||||
expect(opts.env?.CLAUDE_CONFIG_DIR).toMatch(/\/\.claude$/);
|
||||
expect(opts.env?.GSTACK_HOME).toContain('gstack-home');
|
||||
expect(opts.pathToClaudeCodeExecutable).toBe('/fake/path/claude');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user