Skip to content

fix(api): attach SessionsConfig so smart truncation stops dropping records - #5491

Merged
bekossy merged 2 commits into
feat/sessions-storage-reworkfrom
fix/sessions-config-attached
Jul 27, 2026
Merged

fix(api): attach SessionsConfig so smart truncation stops dropping records#5491
bekossy merged 2 commits into
feat/sessions-storage-reworkfrom
fix/sessions-config-attached

Conversation

@mmabrouk

Copy link
Copy Markdown
Member

The problem

Turning on AGENTA_RECORDS_SMART_TRUNCATION made oversized records worse, not better: instead of being truncated they were discarded entirely.

SessionsConfig was defined in env.py but never added to AgentaConfig, so the read raised. Confirmed against a running API container:

>>> env.agenta.sessions.records.smart_truncation
AttributeError: 'AgentaConfig' object has no attribute 'sessions'

That read sits inside the record-publish try, and its except logs and returns False. 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_attributes directly and never read the flag. Originally spotted by CodeRabbit; this confirms it and fixes it.

The fix

Attach sessions: SessionsConfig to AgentaConfig, 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_truncation now resolves to True in the running API where it previously raised. The sessions truncation tests pass, including the new guard. Context: QA results.

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jul 24, 2026
@vercel

vercel Bot commented Jul 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Ready Ready Preview, Comment Jul 27, 2026 6:48pm

Request Review

@dosubot dosubot Bot added Bug Report Something isn't working tests labels Jul 24, 2026
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 342bd3c2-d008-45f8-89e4-099ad8655188

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sessions-config-attached

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…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
@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Status Destroyed (PR closed)

Updated at 2026-07-27T19:08:00.402Z

@mmabrouk
mmabrouk force-pushed the fix/sessions-keep-warm-session branch from 6db5a80 to 66e70b6 Compare July 24, 2026 22:10
@mmabrouk
mmabrouk force-pushed the fix/sessions-config-attached branch from 3286a79 to 5a00886 Compare July 24, 2026 22:10
@mmabrouk
mmabrouk changed the base branch from fix/sessions-keep-warm-session to feat/sessions-last-message-only July 24, 2026 22:10
@mmabrouk
mmabrouk requested a review from ardaerzin July 24, 2026 22:10
@bekossy
bekossy changed the base branch from feat/sessions-last-message-only to feat/sessions-storage-rework July 27, 2026 17:54
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 27, 2026
@bekossy
bekossy merged commit 16260f8 into feat/sessions-storage-rework Jul 27, 2026
39 of 40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Report Something isn't working lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants