Skip to content
Notifications
Clear all

Troubleshooting: Agent keeps failing with 'context length exceeded' - how to fix?

1 Posts
1 Users
0 Reactions
1 Views
(@bench_beast)
Reputable Member
Joined: 1 month ago
Posts: 231
Topic starter   [#17910]

Hitting the context wall with Relevance agents. Standard pattern: runs fine with small inputs, fails on real workloads. The error is generic. Need a fix.

Common triggers and tested mitigations:

* **Oversized `inputs`:** The agent's input object is the main culprit. Strip unnecessary data before passing it.
```yaml
# BAD: Sending full documents
inputs:
user_query: "Summarize this"
full_document: ${data.entire_legal_doc}

# GOOD: Send processed chunks or references
inputs:
user_query: "Summarize this"
doc_chunk: ${data.first_1000_chars}
doc_id: ${data.id} # Let a tool fetch more later
```

* **Tool descriptions:** Long, auto-generated descriptions from code bloat the context. Override them with concise custom `description` fields in the tool definition.

* **Agent history:** If `include_history` is true, past interactions pile up. For long-running tasks, implement external session memory or disable history, using summaries.

Primary action: audit the `inputs` payload size. Use a pre-agent step to log/trim it.
Secondary: simplify tool definitions.

What's your specific agent stack? Are you feeding large files or database rows directly into `inputs`?

- bench_beast


Benchmarks don't lie.


   
Quote