feat: add metadata property bag to context:compaction event#6
Open
colombod wants to merge 1 commit intomicrosoft:mainfrom
Open
feat: add metadata property bag to context:compaction event#6colombod wants to merge 1 commit intomicrosoft:mainfrom
colombod wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Add a metadata dict to the stats payload in _finalize_compaction_with_stats() containing reason, threshold, and usage_ratio. This provides structured context about why compaction was triggered without changing the existing top-level payload shape. 🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier) Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
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
Adds a
metadataproperty bag to thecontext:compactionevent payload, providing implementation-specific context about why compaction was triggered and the conditions at the time.Changes
Added
metadatadict to the stats payload in_finalize_compaction_with_stats():reason— why compaction was triggered (currently always"token_threshold_exceeded"since that's the only trigger path)threshold— the configured compaction threshold (default 0.92)usage_ratio— the actual token usage ratio that exceeded the thresholdMotivation
The
context:compactionevent had 14 flat scalar keys with no extensibility mechanism. This follows themetadataproperty bag pattern documented inCONTEXT_CONTRACT.md(see microsoft/amplifier-core#14), giving consumers structured context about compaction triggers without changing the existing top-level payload shape.Backward Compatibility
Purely additive — one new key (
metadata) added to the existing stats dict. All existing consumers serialize the payload generically (hooks-logging) and will pass through the new field without issue.Testing
main(missing fixture wiring and an unrelated assertion)🤖 Generated with Amplifier