Skip to content

Commit 5a00886

Browse files
committed
fix(api): attach SessionsConfig so smart truncation stops dropping records
`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
1 parent 882eebc commit 5a00886

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

api/oss/src/utils/env.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ class AgentaConfig(BaseModel):
539539
otlp: OTLPConfig = OTLPConfig()
540540
redaction: RedactionConfig = RedactionConfig()
541541
services: ServicesConfig = ServicesConfig()
542+
sessions: SessionsConfig = SessionsConfig()
542543
webhooks: WebhooksConfig = WebhooksConfig()
543544
workers: WorkersConfig = WorkersConfig()
544545

api/oss/tests/pytest/unit/sessions/test_records_truncation.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,14 @@ def test_non_dict_attributes_fall_back():
7171
huge = "z" * (MAX_ATTRIBUTES_BYTES * 2)
7272
out = _truncate_attributes(huge, MAX_ATTRIBUTES_BYTES, _size(huge))
7373
assert out == {"_truncated": True, "_original_bytes": _size(huge)}
74+
75+
76+
def test_smart_truncation_flag_is_reachable_from_the_env_object():
77+
"""The publish path reads `env.agenta.sessions.records.smart_truncation` inside a
78+
try/except that swallows anything and drops the record. When `SessionsConfig` was not
79+
attached to `AgentaConfig` this raised AttributeError, so every over-cap record was
80+
discarded instead of truncated, and the tests above still passed because they call
81+
`_truncate_attributes` directly and never touch the flag."""
82+
from oss.src.utils.env import env
83+
84+
assert isinstance(env.agenta.sessions.records.smart_truncation, bool)

0 commit comments

Comments
 (0)