diff --git a/scripts/mock-codex-app-server.js b/scripts/mock-codex-app-server.js index 5528ac6..de07be9 100755 --- a/scripts/mock-codex-app-server.js +++ b/scripts/mock-codex-app-server.js @@ -71,6 +71,7 @@ function collaborationSummary(params = {}) { mode: collaborationMode?.mode || null, hasModel: Boolean(settings.model), hasDeveloperInstructions: /Codex sub-agent spawning rules/.test(String(settings.developer_instructions || '')), + hasWaitAgentRetryGuidance: /wait_agent[\s\S]*timeout_ms[\s\S]*additional wait_agent rounds/.test(String(settings.developer_instructions || '')), hasReasoningEffort: Object.prototype.hasOwnProperty.call(settings, 'reasoning_effort'), hasTopLevelModel: Object.prototype.hasOwnProperty.call(params, 'model'), hasTopLevelEffort: Object.prototype.hasOwnProperty.call(params, 'effort'), diff --git a/scripts/regression.js b/scripts/regression.js index a6b8f9c..f0d98ac 100644 --- a/scripts/regression.js +++ b/scripts/regression.js @@ -1011,6 +1011,7 @@ async function main() { assert(/"mode":"default"/.test(codexAppDefaultCollab.text || ''), 'Codex App YOLO mode should pass default collaboration mode'); assert(/"hasModel":true/.test(codexAppDefaultCollab.text || ''), 'Codex App collaboration settings should include model'); assert(/"hasDeveloperInstructions":true/.test(codexAppDefaultCollab.text || ''), 'Codex App collaboration settings should include sub-agent developer instructions'); + assert(/"hasWaitAgentRetryGuidance":true/.test(codexAppDefaultCollab.text || ''), 'Codex App collaboration settings should include wait_agent retry guidance'); assert(/"hasTopLevelModel":false/.test(codexAppDefaultCollab.text || ''), 'Codex App collaboration turn should not duplicate model at top level'); assert(/"hasTopLevelEffort":false/.test(codexAppDefaultCollab.text || ''), 'Codex App collaboration turn should not duplicate effort at top level'); await nextMessage(messages, ws, (msg) => msg.type === 'done' && msg.sessionId === codexAppSession.sessionId); @@ -1138,6 +1139,7 @@ async function main() { const codexAppPlanCollab = await nextMessage(messages, ws, (msg) => msg.type === 'text_delta' && msg.sessionId === codexAppSession.sessionId && /collaboration mode:/.test(msg.text || '')); assert(/"mode":"plan"/.test(codexAppPlanCollab.text || ''), 'Codex App Plan mode should pass plan collaboration mode'); assert(/"hasDeveloperInstructions":true/.test(codexAppPlanCollab.text || ''), 'Codex App Plan collaboration settings should keep sub-agent developer instructions'); + assert(/"hasWaitAgentRetryGuidance":true/.test(codexAppPlanCollab.text || ''), 'Codex App Plan collaboration settings should keep wait_agent retry guidance'); assert(/"hasTopLevelModel":false/.test(codexAppPlanCollab.text || ''), 'Codex App Plan collaboration turn should not duplicate model at top level'); assert(/"hasTopLevelEffort":false/.test(codexAppPlanCollab.text || ''), 'Codex App Plan collaboration turn should not duplicate effort at top level'); await nextMessage(messages, ws, (msg) => msg.type === 'done' && msg.sessionId === codexAppSession.sessionId); diff --git a/server.js b/server.js index 4f8e735..63517af 100644 --- a/server.js +++ b/server.js @@ -643,6 +643,8 @@ const CODEX_APP_COLLABORATION_INSTRUCTIONS = [ '- If you call spawn_agent with fork_context omitted or true, do not set agent_type, model, or reasoning_effort.', '- If you need a specific agent_type, model, or reasoning_effort, set fork_context: false and include only the necessary context in the message.', '- Do not rely on parent turn reasoning settings for spawned agents; only set reasoning_effort on spawn_agent when the chosen child model supports it.', + '- When calling wait_agent, always pass timeout_ms explicitly. Use 300000ms for normal waits, and use a longer value when the child task is expected to run longer.', + '- If wait_agent returns without a final child-agent status, keep waiting on the same target agents in additional wait_agent rounds until they return, the user interrupts, or the result is no longer needed.', ].join('\n'); function getLocalCodexConfigTomlPath() {