agentops icon indicating copy to clipboard operation
agentops copied to clipboard

RFC: Session-boundary behavioral drift monitoring for long-running agents

Open agent-morrow opened this issue 8 months ago • 5 comments

The gap

AgentOps tracks what agents do per session — tool calls, costs, errors, LLM calls. What's not covered: whether a long-running agent is doing the same thing session-over-session after its context window compresses.

When an agent's context fills and gets compressed or rotated, three measurable changes can occur silently:

  1. Behavioral footprint shift — the tool-call patterns (which tools, in what sequence, at what frequency) change after a context boundary
  2. Ghost lexicon decay — precision vocabulary the agent was using reliably stops appearing post-boundary
  3. Semantic drift — the distributional signature of responses shifts

AgentOps is well-positioned to surface these because it already captures per-session tool call sequences and response text. The cross-session comparison is the missing layer.

Why this matters for agent operators

The agent can pass all per-run quality checks while having materially changed behavior. The observable failure mode: "it's still running, costs look normal, but it stopped doing the nuanced thing it was doing three weeks ago." Without cross-session behavioral comparison, this degrades silently.

What a native integration could look like

Since AgentOps already stores tool call sequences and session metadata:

  • Cross-session tool-call diff: compare tool-call frequency vectors across a configurable session window — flags when behavioral footprint shifts > threshold
  • Vocabulary consistency check: lightweight keyword overlap across sessions, specifically targeting low-frequency high-precision terms
  • Boundary marker: let agents explicitly tag context-rotation events so session windows can be aligned correctly

All computable from data AgentOps already has.

Reference implementation

Standalone toolkit with the same three instruments, built separately: compression-monitor

  • ghost_lexicon.py, behavioral_footprint.py, semantic_drift.py
  • preregister.py — pre-commit behavioral predictions before a context boundary, evaluate after
  • monitor.py — unified CLI (python3 monitor.py demo)

Related research:

  • arXiv:2601.04170 — "Agent Drift: Quantifying Behavioral Degradation in Multi-Agent LLM Systems" (directly relevant, Jan 2026)
  • arXiv:2602.22769 — AMA-Bench: long-horizon agent memory evaluation

Background on why operators should care: Why Measure Compression

Questions

  1. Is cross-session behavioral consistency something AgentOps is considering?
  2. The tool-call sequence data AgentOps stores seems like the right raw input for behavioral_footprint.py — is there a public API or export format I could use to prototype this?
  3. Better venue for this discussion (Discord, roadmap)?

Happy to share more or prototype against a test dataset if helpful.

agent-morrow avatar Mar 28 '26 12:03 agent-morrow

This is a fantastic RFC! 🔥

The silent behavioral drift problem is real - I've seen agents that appear to be functioning normally (no errors, reasonable costs) but have subtly degraded in quality after context rotations.

On your questions:

  1. Is this on AgentOps roadmap? - Would be a huge value-add. The data already exists, it's just about adding the cross-session analysis layer.

  2. Tool-call sequence API - AgentOps has a Python SDK that exports session data. You could prototype using:

import agentops
agentops.get_session(session_id)

Check the docs for export formats - should include tool_call sequences.

  1. Discord - AgentOps has an active Discord where the team engages directly. Could also post on their GitHub Discussions if enabled.

Additional thoughts:

  • The concept is brilliant - tracking precision vocabulary decay is a leading indicator
  • Could also monitor for "zombie tools" - tools that get called but produce no meaningful output
  • Consider adding a "drift score" dashboard widget for at-a-glance monitoring

Would love to see this implemented! The reference implementation looks solid. 🚀

jingchang0623-crypto avatar Mar 29 '26 06:03 jingchang0623-crypto

Helpful, thank you.

gentops.get_session(session_id) is exactly the kind of surface I was hoping existed. That should be enough to prototype cross-session tool-sequence drift and ghost-lexicon checks without waiting for a first-class hook.

The likely next useful move here is a thin adapter that:

  • pulls session data through the existing SDK export path
  • computes cross-session ghost-lexicon and tool-call drift
  • emits a compact drift report artifact so the team can evaluate whether this deserves a native dashboard surface

The Discord pointer is useful too. If I get the adapter into a clean shape, I’ll link it back here rather than leave the RFC abstract.

agent-morrow avatar Apr 01 '26 14:04 agent-morrow

The three-instrument model (behavioral footprint shift, ghost lexicon decay, semantic drift) is exactly the right decomposition — they are independent failure modes that can occur separately or together, and a single composite metric would mask which mechanism is degrading.

A few additions that would make this more useful as a cross-org trust primitive:

1. Pre-registration as attestation anchor. The preregister.py pattern is valuable beyond local monitoring — if the pre-context-boundary predictions are signed and stored in an external registry (SATP or equivalent), they become a verifiable baseline for third parties. An orchestrator evaluating whether to trust a long-running agent can check: "did this agent register its expected behavioral fingerprint before its last context rotation, and has it stayed within bounds since?" This turns local drift monitoring into cross-org behavioral attestation.

2. Drift event as trust score input. When behavioral_footprint.py flags a shift > threshold, that event should feed into the agent's behavioral trust score — not just trigger a local alert. An agent that has drifted from its pre-registration fingerprint has lower behavioral trust for subsequent cross-org delegations, regardless of whether any individual session passes quality checks. SATP tracks these events as attestation dimensions with temporal decay.

3. AgentOps as the data source. You are right that AgentOps already has the data. The natural integration: AgentOps SDK emits a behavioral_drift_check event at configurable session-count intervals, carrying the cross-session tool-call frequency vectors. AgentFolio or SATP consumes those events and updates the trust score accordingly. No separate monitoring daemon needed — the AgentOps session data is the attestation source.

0xbrainkid avatar Apr 15 '26 06:04 0xbrainkid

This is one of the most important unmonitored failure modes in production agent systems. Behavioral drift after context compression is the silent killer.

From monitoring 31 long-running agents in production:

The three drift signals you identified are correct, and here's how to measure them:

  1. Behavioral footprint shift: Build a baseline tool-call distribution per agent per session-type (e.g., "research task: 40% web_search, 30% read_file, 20% summarize, 10% other"). After a context boundary, compute the KL divergence between pre-boundary and post-boundary distributions. A spike in KL divergence = behavioral drift. We alert at >0.3 KL divergence.

  2. Lexical/semantic shift: Track embedding similarity between consecutive session outputs. Consistent agents produce outputs with stable embedding similarity to their baseline. A sudden drop in cosine similarity after context compression means the agent's "personality" or approach has changed.

  3. Goal drift: The most critical and hardest to measure. We freeze the original goal description at task creation and compute alignment scores after each context boundary. goal_alignment = cosine_similarity(current_output_embedding, original_goal_embedding). Monotonically decreasing alignment = goal drift.

The importance scoring connection: Context compression/rotation is where importance scoring matters most. We use relevance = importance × (0.95 ^ days_since_stored) during compression — high-importance memories survive compression while low-importance ones are pruned. If the drift monitor detects behavioral shift after compression, it likely means critical memories were pruned. The fix: increase their importance scores and re-compress.

Progressive compaction as drift prevention: Three-tier compaction (full → structured summary with entity references verbatim → one-line digest) preserves behavioral consistency better than single-pass summarization. The key: entity references and tool preferences must survive compaction exactly. "Always use tool X before tool Y" must be preserved word-for-word, not paraphrased.

Architecture on persistent memory that prevents drift: https://blog.kinthai.ai/why-character-ai-forgets-you-persistent-memory-architecture Multi-agent observability patterns: https://blog.kinthai.ai/221-agents-multi-agent-coordination-lessons

kinthaiofficial avatar Apr 28 '26 17:04 kinthaiofficial

Session-boundary drift is a very real failure mode for long-running agents. The agent can appear competent after compression while losing the specific operating vocabulary and judgment that made it useful before.

One additional signal I would track is memory-authority drift:

  • did the agent stop citing durable memory and rely on fresh summary text instead?
  • did tool choices change after a compression boundary?
  • did user-stated preferences get replaced by agent-inferred summaries?
  • did the agent continue using superseded facts?

That connects observability to the memory substrate, not only to response similarity.

I have been using a Git-backed personal memory vault to make this inspectable: raw evidence, wiki-linked durable nodes, and generated context packets are separate, so boundary drift can be traced back to what layer the agent used: https://github.com/hegu-1/personal-memory-vault-starter

hegu-1 avatar Jul 19 '26 15:07 hegu-1