session_detect_drift
Detects when an agent session diverges from its original goal by scoring semantic alignment. Provides warnings for goal drift, context collapse, and quality degradation.
Instructions
Detect whether the current agent session has semantically drifted from its original goal. Scores recent ledger entries against the goal using synalux's HRR embedding stack (GloVe → Gemini/Voyage → cosine similarity), then runs the rolling-window drift detector algorithm.
Triggers:
goal-drift— cumulative alignment loss is high and monotonic (not random tangents)context-collapse— average output quality has dropped below floor
Pre-warning:
quality-degrading— quality slope steeply negative before collapse
Returns: drifted, reason, warning, drift_score (0..1), goal_alignment, quality_avg, sample_count, adaptive_threshold, recommendation.
Use alongside GATE 5 (60-minute drift check): call this tool instead of session_cognitive_route for goal-alignment drift detection.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| goal | Yes | The original session goal — the task you started this session to accomplish. Used as the semantic reference vector. Be specific: 'implement drift detection for prism-mcp' is better than 'work on prism'. | |
| domain | No | Optional domain for domain-specific drift signals. 'coder' adds file_entropy, summary_vagueness, test_coverage_ratio, trajectory_divergence. 'bcba' adds clinical_specificity, function_aligned, contraindication_safe (requires behavior_functions, contraindications, client_descriptors params). 'aac' is reserved for future AAC prediction drift (use the AAC-specific endpoint instead). | |
| project | Yes | Project identifier. Must match the project used in session_save_ledger. | |
| window_hours | No | How many hours of ledger history to evaluate. Default 1. Range 0.083–24 (5 min to 24 h). | |
| assessment_type | No | BCBA domain only: assessment instrument name (e.g. 'vb-mapp', 'vineland', 'ablls-r'). | |
| conversation_id | No | Optional. Session key (same id used in session_load_context). When provided, resets the server-side drift timer for this conversation. | |
| contraindications | No | BCBA domain only: known medical conditions (e.g. ['epilepsy', 'pica']). | |
| behavior_functions | No | BCBA domain only: identified behavior functions for this client (e.g. ['escape-maintained', 'attention-maintained']). | |
| client_descriptors | No | BCBA domain only: client-specific terms to check for specificity (e.g. ['7-year-old', 'aggression at transitions']). | |
| min_directional_ratio | No | Directional ratio floor for the tremor filter (0..1). Random topic tangents that return to the goal are suppressed below this threshold. Default 0.2. Set to 0 to disable filter. |