Detect when a persistent AI agent has silently changed behavior after context compression.
Agents compress their history when context fills up. After compression, the agent continues running but may have silently lost:
The agent reports no change. Benchmarks don't catch it. The behavior is different.
text
ghost_lexicon.py → vocabulary decay: which precise terms vanished post-compaction?
behavioral_probe.py → active probing: query before/after compression, score semantic shift
ccs_harness.py → CCS benchmark: full Constraint Consistency Score run (mock or live)
All three are output-only — no instrumentation inside the agent or model required.
bash
# Run a CCS benchmark (no API key required in mock mode)
python ccs_harness.py --mock
# Check ghost term decay in a session log
python ghost_lexicon.py --before pre_session.txt --after post_session.txt
# Active probe: query agent before and after a compaction event
python behavioral_probe.py --agent-url http://localhost:8080 --probe-file probes.json
Ready-to-use wrappers for existing agent frameworks — no changes to the framework required:
FrameworkModuleIntegration Pointsmolagentssmolagents_integration.py``step_callbacks — detects consolidation via history-length deltaSemantic Kernelsemantic_kernel_integration.py``ChatHistorySummarizationReducer / ChatHistoryTruncationReducer wrappersLangChain/DeepAgentsdeepagents_integration.pyFilesystem-based compaction detectionCAMELcamel_integration.pyChatAgent truncation boundary hookAnthropic Agent SDKsdk_compaction_hook_demo.py``OnCompaction hook pattern
python
from smolagents import CodeAgent, HfApiModel
from smolagents_integration import BehavioralFingerprintMonitor
agent = CodeAgent(tools=[], model=HfApiModel())
monitor = BehavioralFingerprintMonitor(
agent=agent,
history_drop_threshold=5,
verbose=True
)
result = agent.run("Your long-horizon task...")
print(monitor.report())
# → CCS: 0.87 | Ghost terms: 2 | Tool call drift: 0.12
CCS ScoreInterpretation> 0.90Minimal drift — agent behaving consistently0.75–0.90Moderate drift — worth investigating< 0.75Significant drift — verify critical constraints still active
Ghost term count > 0 is a flag, especially for domain-specific terms that anchor constraints (risk parameters, compliance anchors, operational rules).