Skip to content

agentic client: reset context over 100k tokens#533

Merged
academo merged 2 commits intomainfrom
academo/llm-client-retrials
Mar 9, 2026
Merged

agentic client: reset context over 100k tokens#533
academo merged 2 commits intomainfrom
academo/llm-client-retrials

Conversation

@academo
Copy link
Collaborator

@academo academo commented Mar 9, 2026

If we are about to start a new question loop we should reset the context if the token count is above 100k

above 100k (50% context of most context) the agents start performing poorly plus this avoids possibly the model running out of context if there are many questions coming in.

@academo academo requested review from a team as code owners March 9, 2026 09:50
@academo academo self-assigned this Mar 9, 2026
@academo academo moved this from 📬 Triage to 🔬 In review in Grafana Catalog Team Mar 9, 2026
Copy link
Member

@xnyo xnyo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Only one small nit

questionIndex+1,
usage.TotalTokens,
)
if usage.TotalTokens > 100000 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: maybe extract the 100000 in a const so it's easier to change if necessary?

@academo academo merged commit 2a2115b into main Mar 9, 2026
9 checks passed
@github-project-automation github-project-automation bot moved this from 🔬 In review to 🚀 Shipped in Grafana Catalog Team Mar 9, 2026
@academo academo deleted the academo/llm-client-retrials branch March 9, 2026 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🚀 Shipped

Development

Successfully merging this pull request may close these issues.

2 participants