feat(chat): add session context budget API and chat budget visibility panel#237
Open
Congregalis wants to merge 2 commits intodataelement:mainfrom
Open
feat(chat): add session context budget API and chat budget visibility panel#237Congregalis wants to merge 2 commits intodataelement:mainfrom
Congregalis wants to merge 2 commits intodataelement:mainfrom
Conversation
601d5a2 to
d0ba16c
Compare
d0ba16c to
5d08051
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces session-level context budget visibility in two parts:
Commits included:
What Changed
1) Backend: Session Context Budget Endpoint
Added:
GET /api/agents/{agent_id}/sessions/{session_id}/context-budgetReturns minimal budget fields:
window_size_messagessession_messages_totalestimated_tokens_current_windowbudget_tokensusage_ratioImplementation notes:
budget_tokensbaseline for now.2) Frontend: Context Budget Indicator in Chat UI
Added session budget visualization in Agent Detail chat:
usage_ratio.Notes / Scope
ScreenShots
Follow-up
To keep this PR focused and easier to review, I’ve kept it to the context‑budget endpoint and UI only, and would implement auto compaction logic separately if you think it’s a good fit for the project.
A follow‑up PR with auto compaction would:
proactively reduce the risk of context overflow and hard failures when long‑running sessions grow large;
avoid silent quality degradation from models receiving overly long, noisy histories;
Checklist