Repository navigation
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
dargoner
force-pushed
the
refactor/unify-context-token-accounting
branch
from
October 18, 2026 13:13
b248f4f to
f1ee22c
Compare
…n context accounting
dargoner
force-pushed
the
refactor/unify-context-token-accounting
branch
from
October 29, 2026 12:07
f1ee22c to
ae77c76
Compare
…t-token-accounting
This branch has not been deployed
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.
AgentScope-Java Version
2.1.0-SNAPSHOT (based on
main@ 5f7f8e6)Description
Background
Context-budget accounting was spread across several call sites with different conventions: the final-request budget ignored provider-level default output schemas (Ollama
format, OpenAI/OpenAI-Responsesresponse_format, and the Anthropic/DashScope/Gemini equivalents) that the adapters actually send on the wire; media charging was duplicated between estimators; and the pruning pass accumulated token counts inint, which can overflow on very large histories.Changes
TokenAccountingService,MediaTokenEstimator): a single place that prices a request (text + tools + media + output reservation + response-format schemas), reused by budget checks, compaction and tests.Model,SessionModels,ReActAgent,HarnessContextBuilder): models exposegetDefaultOptions()/resolveOptions(); the context builder budgets what the provider will actually send (explicit options merged over provider defaults). Default response schemas are now charged for OpenAI, OpenAI official (Responses), DashScope, Anthropic, Gemini and Ollama, withformatsemantics aligned to the provider's effective wire format (including JSON-representation detection for Ollama object schemas).ConversationCompactor,TokenCounterUtil): accumulation widened tolongand per-result accounting aligned with the retained/pruned split.Tests
ContextBudgetRegressionTest(9),ProviderDefaultSchemaBudgetTest(21),TokenAccountingServiceTest(10).HarnessContextBuilderTest8 → 12,ConversationCompactorTestextended.main: 6433 tests, 0 failures / 0 errors (43 environment skips).mvn spotless:checkpasses.Checklist
mvn spotless:applymvn test)