fix: derive context_compaction capability from controls, remove has_hook config - #139
Merged
tishachawla-jg merged 2 commits intoSep 17, 2026
Conversation
Collaborator
|
Hi @RjyavardhanSingh, can you please resolve the conflicts also examples/config/default.yaml also swaps model: gpt-4o-mini → gemini-2.0-flash in 5 places while keeping provider: openai. That's unrelated to this fix and an inconsistent config (OpenAI provider + Gemini model won't resolve), looks like a local-testing artifact. Could you revert those 5 lines? |
6 tasks
Contributor
Author
|
@tishachawla-jg Got it, will fix both unning ruff format on context_compaction.py and reverting the gemini model changes in examples/config/default.yaml. Should be ready shortly. i had changed that for local testing but forgot to restore my bad sorry for that |
…ook config context_compaction took a has_hook flag that no other policy has. It described host capability (whether the prompt-assembly hook exists) as a governance config field — mixing intent with capability. The three defaults disagreed (code: True, yaml: false, admin: false), and the shipped default was wrong for the documented integration path (wrap_complete already supplies the hook). - Remove has_hook from ContextCompactionPolicy, build(), config template, default.yaml, admin UI, and all example configs - Add compaction_supported flag to ApplyControls, set by wrap_complete - Policy reads capability via context variable set in Governor._enforce() - Log a one-time warning when compaction degrades to telemetry - Update tests, docs, and changelog Closes theagentplane#138
RjyavardhanSingh
force-pushed
the
fix/138-context-compaction-defaults
branch
from
September 16, 2026 18:58
7dc962a to
e6986d4
Compare
tishachawla-jg
approved these changes
Sep 17, 2026
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.
Problem
Fixes #138
context_compactionwas the only policy with ahas_hookflag — a host capability masquerading as governance config. Three defaults disagreed (code:True, yaml:false, Admin UI:false), and the shipped default was wrong for the documented integration path:wrap_completealready supplies the prompt-assembly hook, so every Tier-1 quickstart user has the hook but the config said they didn't.The policy appeared enabled in the dashboard while silently doing nothing.
What changed
has_hookfromContextCompactionPolicy,build(), config template,default.yaml, Admin UI placeholder, and all example/benchmark configscompaction_supportedtoApplyControls— set bywrap_completewhich IS the hook_current_controls) set inGovernor._enforce(), so the policy reads controls instead of a config flagWhy this approach
Option 1 from the issue: "derive it." Capability belongs with actuator plumbing, not a governance record.
wrap_completeadvertises the capability because it IS the hook — correct by construction, no config needed.A context variable avoids changing the
Policy.decide()ABC (which would require updating all 10 policies).Files changed
src/tokenops/control/policies/context_compaction.pyhas_hook, derive from controls, add warningsrc/tokenops/control/engine.pycompaction_supportedtoApplyControls, set context var in_enforce()src/tokenops/control/context.py_current_controlsContextVar + helperssrc/tokenops/control/integration.pycontrols.compaction_supported = Trueinwrap_completesrc/tokenops/control/config.pyhas_hookfrom templatesrc/tokenops/config/default.yamlhas_hooksrc/tokenops/ui/views/admin.pyhas_hookfrom placeholdertests/test_context_compaction.pytests/test_actuators.pyhas_hookfrom build calltests/test_policies_wrap_integration.pyhas_hookfrom build callbenchmarking/*/configs.py(3 files)has_hookfrom configsexamples/config/*.yaml(5 files)has_hookfrom configsdocs/policies/context_compaction.mdCHANGELOG.mdAcceptance criteria
has_hookentirely)docs/policies/context_compaction.mdstates where hook comes fromBehaviour change
Anyone relying on
context_compactionbeing silently inert will now get working compaction (prompts rewritten). This is the fix, not a regression — documented in changelog.Non-scope
_compact_messagesquality (only reachability matters here)wrap_streamat:391) — issue Multimodal stream governance: implement wrap_stream and time-windowed accrual (spec) #110's territory