Skip to content

feat(subagent): enforce explicit summary output from subagents#301

Merged
echobt merged 1 commit intomasterfrom
feat/enforce-subagent-summary
Jan 27, 2026
Merged

feat(subagent): enforce explicit summary output from subagents#301
echobt merged 1 commit intomasterfrom
feat/enforce-subagent-summary

Conversation

@echobt
Copy link
Contributor

@echobt echobt commented Jan 27, 2026

Summary

When a subagent completes without providing a structured summary, the executor now requests an additional turn specifically asking for a summary. This ensures subagents always return properly formatted output for the orchestrator to process.

Problem

Subagents were terminating without providing a proper final summary to the orchestrator. This made it difficult for the orchestrator to:

  • Know what tasks were actually completed
  • Track the subagent's progress
  • Coordinate with other agents

Example from user's history shows the agent only marked 2 of 6 tasks as completed and terminated without any summary output.

Solution

Following the pattern from OpenAI's Codex (--session-summary feature), we now:

  1. Detect missing summaries: Added has_summary_output() function that checks for summary markers like:

    • ## Summary for Orchestrator
    • ### Tasks Completed
    • Status: COMPLETED
  2. Request explicit summary: When a subagent completes without a summary, we send an additional turn with SUMMARY_REQUEST_PROMPT that explicitly asks for the structured format.

  3. Combine responses: The original response is combined with the summary to provide complete output.

  4. Track token usage: Token counts from both turns are properly aggregated.

Changes

  • cortex-engine/src/tools/handlers/subagent/executor.rs:
    • Added SUMMARY_REQUEST_PROMPT constant
    • Added has_summary_output() function with tests
    • Modified run_subagent() to request summary turn when needed

Testing

  • Added unit tests for has_summary_output()
  • All existing tests pass
  • Verified with cargo check and cargo fmt

When a subagent completes without providing a structured summary, the
executor now requests an additional turn specifically asking for a summary.
This ensures subagents always return properly formatted output for the
orchestrator to process.

The fix:
- Adds has_summary_output() function to detect summary markers in output
- Requests explicit summary turn if output doesn't contain summary markers
- Uses SUMMARY_REQUEST_PROMPT constant with structured format requirements
- Combines original response with summary in the final result
- Properly tracks token usage across both turns

This follows the Codex pattern of ensuring structured agent output and
resolves the issue where subagents would terminate without providing
feedback to the orchestrator.
@echobt echobt merged commit 335dec4 into master Jan 27, 2026
2 of 3 checks passed
@echobt echobt deleted the feat/enforce-subagent-summary branch January 27, 2026 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants