Skip to content

Commit 2f9ce40

Browse files
authored
Merge pull request #80 from AgentWorkforce/fix/agent-relay-322-spawner-model-config
2 parents d137b1f + e29a19c commit 2f9ce40

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/bridge/spawner.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { resolveCommand } from '../utils/command-resolver.js';
1212
import { PtyWrapper, type PtyWrapperConfig, type SummaryEvent, type SessionEndEvent } from '../wrapper/pty-wrapper.js';
1313
import { selectShadowCli } from './shadow-cli.js';
1414
import { AgentPolicyService, type CloudPolicyFetcher } from '../policy/agent-policy.js';
15+
import { buildClaudeArgs } from '../utils/agent-config.js';
1516
import type {
1617
SpawnRequest,
1718
SpawnResult,
@@ -265,6 +266,16 @@ export class AgentSpawner {
265266
args.push('--dangerously-skip-permissions');
266267
}
267268

269+
// Apply agent config (model, --agent flag) from .claude/agents/ if available
270+
// This ensures spawned agents respect their profile settings
271+
if (isClaudeCli) {
272+
const configuredArgs = buildClaudeArgs(name, args, this.projectRoot);
273+
// Replace args with configured version (includes --model and --agent if found)
274+
args.length = 0;
275+
args.push(...configuredArgs);
276+
if (debug) console.log(`[spawner:debug] Applied agent config for ${name}: ${args.join(' ')}`);
277+
}
278+
268279
// Add --dangerously-bypass-approvals-and-sandbox for Codex agents
269280
const isCodexCli = commandName.startsWith('codex');
270281
if (isCodexCli && !args.includes('--dangerously-bypass-approvals-and-sandbox')) {

src/utils/agent-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export function buildClaudeArgs(
138138
const config = findAgentConfig(agentName, projectRoot);
139139

140140
if (!config) {
141-
return existingArgs;
141+
return [...existingArgs]; // Return a copy to avoid reference issues
142142
}
143143

144144
const newArgs = [...existingArgs];

0 commit comments

Comments
 (0)