Skip to content

[FEAT]: implement conversation history pruning when approaching context limits #4

Description

@Nithwin

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

  1. Add token usage threshold checks inside internal/agent/loop.go.
  2. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions