Is your feature request related to a problem? Please describe.
Problem
Long multi-turn conversations cause the []ai.Message history to grow excessively large, wasting input tokens and triggering context size (400 Bad Request) or Tokens Per Minute (TPM) rate limits.
Describe the solution you'd like
Proposed Solution
- Add token usage threshold checks inside
internal/agent/loop.go.
- When approaching context limits, automatically truncate or summarize the oldest conversation turns (
user/assistant/tool outputs) while strictly preserving the system instructions (prompt.Build()) and recent tool context.
Describe alternatives you've considered
No response
Additional Context
No response
Is your feature request related to a problem? Please describe.
Problem
Long multi-turn conversations cause the
[]ai.Messagehistory to grow excessively large, wasting input tokens and triggering context size (400 Bad Request) or Tokens Per Minute (TPM) rate limits.Describe the solution you'd like
Proposed Solution
internal/agent/loop.go.user/assistant/tooloutputs) while strictly preserving the system instructions (prompt.Build()) and recent tool context.Describe alternatives you've considered
No response
Additional Context
No response