Publish enriched Lody ACP usage and compaction activity - #17
Draft
leynos wants to merge 1 commit into
Draft
Conversation
Preserve provider-reported reasoning token counts, including Baseten's nested Chat Completions field, and expose them through normalized Lody usage updates without double-counting visible output. Resolve context windows and opt-in custom-provider pricing from model profiles so ACP clients can display context capacity and calculated USD costs. Publish automatic compaction through standard ACP tool lifecycle updates. Keep rate-limit capability advertising conservative. Surface real 429 metadata and Retry-After values through telemetry and notices without inventing quota windows or reset percentages.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueWarning Your free Security trial is over. An organization admin can activate Security or dismiss this notice. Comment |
Reviewer's GuideThis PR extends VTCode’s normalized usage pipeline to retain provider reasoning tokens, resolves optional context and pricing metadata for enriched Lody usage updates, adds standard ACP lifecycle reporting for automatic compaction, and surfaces conservative HTTP 429 notices while deliberately omitting untrustworthy quota metadata. Sequence diagram for enriched Lody usage reportingsequenceDiagram
participant Provider
participant Parser
participant UsagePipeline
participant ZedAgent
participant ACPClient
Provider->>Parser: usage response with reasoning_tokens
Parser->>UsagePipeline: normalized Usage
UsagePipeline->>ZedAgent: publish_lody_usage(provider, model, response)
ZedAgent->>ZedAgent: lody_usage_profile(provider, model)
ZedAgent->>UsagePipeline: estimate_session_costs_with_pricing
ZedAgent->>ACPClient: _lody/session/usage_update
Note over ACPClient: contextWindow, reasoningOutputTokens, costUSD
Sequence diagram for automatic compaction activitysequenceDiagram
participant ZedAgent
participant CompactionActivity
participant ACPClient
ZedAgent->>CompactionActivity: begin(session_id, prompt_tokens)
CompactionActivity-->>ZedAgent: started_update()
ZedAgent->>ACPClient: tool_call: in_progress
ZedAgent->>ZedAgent: compact conversation
ZedAgent->>CompactionActivity: finished_update(used_tokens_after, failure_reason)
CompactionActivity-->>ZedAgent: tool_call_update
ZedAgent->>ACPClient: tool_call_update: completed or failed
Flow diagram for conservative rate-limit reportingflowchart TD
Error[Provider error] --> Metadata{HTTP 429 metadata?}
Metadata -->|No| Telemetry[Provider telemetry only]
Metadata -->|Yes| Notice[publish_rate_limit_notice]
Notice --> Retry{Automatic retry scheduled?}
Retry -->|Yes| Warning[Warning with Retry-After and retry delay]
Retry -->|No| WarningNoRetry[Warning with no further retry]
Warning --> ACPClient[ACP session_info_update]
WarningNoRetry --> ACPClient
Metadata -.->|No quota window calculated| Omit[Omit lody.rateLimits]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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 branch enriches VTCode's negotiated Lody ACP metadata so clients can
display provider-reported reasoning usage, resolved context capacity,
opt-in calculated costs and automatic compaction activity. It is stacked on
#14 and keeps rate-limit reporting deliberately conservative.
Baseten's nested reasoning-token field is preserved through the normalized
usage pipeline. Custom providers can supply per-million-token pricing at the
provider or model-profile level; VTCode then publishes
costUSDalongsidethe resolved
contextWindow. Automatic compaction is represented by standardACP tool lifecycle updates with
_meta.lody.activity.Review walkthrough
Validation
./scripts/check.sh: passed formatting, workflow security, structuredlogging, 72 ast-grep rule tests, Clippy with warnings denied, build,
documentation and all release gates; 6,588 tests passed, 16 were skipped,
and two pre-existing flaky tests passed on configured retry.
cargo nextest run --locked -p vtcode-acp -E 'test(/lody_|compaction|advertised_capabilities|provider_error_telemetry/)': 23 passed.cargo nextest run --locked -p vtcode-config -E 'test(custom_provider)': 22 passed.cargo nextest run --locked -p vtcode-llm -E 'test(/parse_usage_openai_format|test_from_llm_usage_preserves_reasoning_output_tokens|openai_chat_stream_usage_obeys_profile_precedence_and_decodes_terminal_usage/)': 8 passed, including Baseten Wiremock playback.git diff --check: passed.Notes
VTCode does not advertise
_meta.lody.rateLimits: Baseten does not currentlyprovide a trustworthy quota window from which to calculate usage percentages
or reset times. Real HTTP 429 status, error detail and
Retry-Aftervalues arepublished through provider telemetry and negotiated Lody notices instead.
Summary by Sourcery
Enrich Lody ACP metadata with provider usage, cost, context, compaction, and conservative rate-limit activity reporting.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: