Long log searches are filling your main agent's context. Which design helps most?
Why D is the answer
Delegate the search to a subagent and keep only its summary
A subagent runs in its own context window, so bulky output stays there. Only the summary returns. max_tokens limits the reply, not what the conversation holds.
In detail
- Every log line an agent reads stays in its context and is sent again on later turns.
- A subagent does the noisy reading in its own context, and the main agent receives only the summary.
- The main conversation stays small, so it stays focused and cheaper to continue.
- Ask the subagent for the specific result you need, so its summary stays short.
Use case
An illustrative scenario, not a real incident.
An incident agent reads thousands of log lines and soon runs short of context. Sending the search to a subagent keeps those lines out of the main conversation, and the main agent receives a few sentences on what was found.
See it in different ways
flowchart LR A["Coordinator"] -->|"Task plus findings"| B["Research subagent"] B -->|"Summary"| A A -->|"Task plus summary"| C["Synthesis subagent"] C -->|"Report"| A
sequenceDiagram participant C as Coordinator participant S as Subagent C->>S: Task text, with everything it needs S->>S: Reads, searches and thinks in its own context S-->>C: Final summary only
stateDiagram-v2 state "Main agent" as s0 state "Subagent searches logs" as s1 state "Summary returned" as s2 state "Main agent continues" as s3 [*] --> s0 s0 --> s1: delegate s1 --> s2: finish s2 --> s3 s3 --> [*]
Key point: Subagents keep noisy work out of the main context.
Why the other options are wrong
- A. Raise max_tokens so that the agent can hold more search output
- max_tokens limits the length of a reply. It does not change how much context the conversation can hold.
- B. Tell the agent in the system prompt to read fewer lines of each log
- The agent may still need to search the logs, and a prompt instruction does not guarantee smaller output.
- C. Restart the session each time a search returns more than a few pages
- Restarting throws away useful progress along with the noise.

