fix(api): attach SessionsConfig so smart truncation stops dropping records - #5491
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…cords `SessionsConfig` was defined but never added to `AgentaConfig`, so reading `env.agenta.sessions.records.smart_truncation` raised AttributeError. That read sits inside the record-publish try/except, whose handler logs and returns False, so with AGENTA_RECORDS_SMART_TRUNCATION on every record over the 64 KB cap was discarded outright. The legacy path it replaces at least stored a marker, and records are now the only copy of the conversation, so a dropped record is lost context. The existing tests call `_truncate_attributes` directly and never read the flag, which is why they stayed green while the feature was unreachable. Added a guard that pins the config path itself. Claude-Session: https://claude.ai/code/session_01KM69J7uHafgciiN5zfG7qR
Railway Preview Environment
Updated at 2026-07-27T19:08:00.402Z |
6db5a80 to
66e70b6
Compare
3286a79 to
5a00886
Compare
The problem
Turning on
AGENTA_RECORDS_SMART_TRUNCATIONmade oversized records worse, not better: instead of being truncated they were discarded entirely.SessionsConfigwas defined inenv.pybut never added toAgentaConfig, so the read raised. Confirmed against a running API container:That read sits inside the record-publish
try, and itsexceptlogs and returnsFalse. So any record body over the 64 KB cap failed to publish at all. The legacy path it was meant to improve on at least stored{"_truncated": True}, and since records are now the only copy of the conversation used to rebuild model context, a dropped record is lost context rather than a lost detail in a viewer.The existing tests stayed green throughout, because they call
_truncate_attributesdirectly and never read the flag. Originally spotted by CodeRabbit; this confirms it and fixes it.The fix
Attach
sessions: SessionsConfigtoAgentaConfig, and add a test that pins the config path itself rather than only the helper, so an unreachable flag fails the suite instead of passing it.Testing
env.agenta.sessions.records.smart_truncationnow resolves toTruein the running API where it previously raised. The sessions truncation tests pass, including the new guard. Context: QA results.