Fix #582: include closed sessions in drift baselines - #725
Conversation
Explicitly closed sessions are terminal history, but the DuckDB drift queries only selected sessions marked completed. This prevented valid history from reaching baseline thresholds. Use the shared terminal-status set for both storage reads and pin the full baseline path with a closed-plus-completed regression fixture. Closes Metabuilder-Labs#582 Co-Authored-By: anshss <noreply@github.com>
|
| Filename | Overview |
|---|---|
| tokenjam/core/db.py | Broadens both drift-history queries to closed and completed sessions using correctly matched parameterized placeholders. |
| tests/synthetic/test_drift_detection.py | Adds end-to-end regression coverage proving closed and completed sessions jointly satisfy baseline construction. |
Reviews (1): Last reviewed commit: "fix: include closed sessions in drift ba..." | Re-trigger Greptile
|
Merged — thanks @sanmaxdev. Three things I want to call out specifically, because they're the parts that made this quick to review: You consumed the existing The measured shift in the PR body is reproducible to the digit. I re-ran It also fixes a second bug you didn't claim. Those two methods have six other callers. One optional follow-up, not for this PR: both methods are still named |
Explicitly closed sessions were valid terminal history, but the DuckDB drift queries selected only sessions marked
completed. Agents using the close endpoint could therefore miss valid history and fail to form a drift baseline.Summary
TERMINAL_STATUSESset in both DuckDB drift-history queriesRelated issue
Closes #582
Behavior verified
The synthetic fixture contains one
closedsession and onecompletedsession for the same agent.sessions_sampled == 2Tests / Verification
assert 1 == 2pytest tests/synthetic/test_drift_detection.py::test_terminal_sessions_feed_drift_baseline -vpassedpytest tests/unit/ tests/synthetic/ tests/agents/ tests/integration/ -qpassed: 5,586 passed, 18 skipped, 2 xfailedruff check tokenjam/cleanmypy tokenjam/cleangit diff --checkcleanWhat's NOT in this PR
Checklist
pytest tests/unit/ tests/synthetic/ tests/agents/ tests/integration/)ruff check tokenjam/)mypy tokenjam/)tests/factories.py(not rawNormalizedSpan)@anilmurty ready for review.