Skip to content

feat: turn the session-storage rework on by default - #5560

Open
mmabrouk wants to merge 2 commits into
release/v0.106.1from
feat/sessions-flags-default-on
Open

feat: turn the session-storage rework on by default#5560
mmabrouk wants to merge 2 commits into
release/v0.106.1from
feat/sessions-flags-default-on

Conversation

@mmabrouk

@mmabrouk mmabrouk commented Jul 29, 2026

Copy link
Copy Markdown
Member

Context

The session-storage rework shipped dark in v0.106.1: durable record persistence in the runner (AGENTA_RECORDS_DURABLE), history reconstruction from records (AGENTA_SESSIONS_RECONSTRUCT), and last-message-only sends from the web app (NEXT_PUBLIC_SESSIONS_LAST_MESSAGE_ONLY). All three defaulted to off and only the literal "true" enabled them. The feature was QA'd on a dedicated stack with the flags on and the findings from that pass are fixed and merged, so the flags should now be the default path.

Change

All three read sites flip to on unless explicitly disabled: the predicate is now value !== "false" (case-insensitive, trimmed) instead of value === "true".

Absent AND empty both mean on, deliberately. The compose files pass the variables through as ${VAR:-}, which materializes an empty string when the variable is unset in the shell, and a compose environment: entry overrides env_file. A changed fallback string alone would therefore have left every compose deployment off. Only the literal "false" disables.

Before: unset, empty, or anything but "true" → feature off.
After: unset, empty, or anything but "false" → feature on. Set the variable to false to disable.

Also in this commit:

  • Stale "off by default / flag-gated no-op" comments corrected at the read sites and in the compose files; the four env.*.example files now document the flags as default-on with =false to disable.
  • services/runner/tests/setup/hermetic-env.ts pins AGENTA_SESSIONS_RECONSTRUCT=false: with the new default, 75 engine unit tests would otherwise reach for a live records endpoint. The reconstruct suite deletes the pin to test the real default.
  • Unit tests updated and extended: each flag now has explicit absent=on, empty=on, and "false"=off cases.

AGENTA_RECORDS_SMART_TRUNCATION (a fourth, API-side flag) is out of scope and stays opt-in.

Tests

  • Runner: 1292/1292 unit tests green (82 files) + typecheck clean.
  • @agenta/playground: 211/211 green. @agenta/shared: 294/294 green.
  • pnpm lint-fix clean, reformatted nothing.

What to QA

  • A fresh EE dev deploy with none of the three variables set: sessions persist durably (runner logs show [sessions/persist] ingest OK), a resumed conversation reconstructs from records, and the web app sends only the trailing message on a turn.
  • Set all three to false and recreate runner + web: behavior returns to the pre-rework path (full history sent, no durable ingest).
  • Regression: the runner unit suite stays hermetic (no network calls from engine tests).

https://claude.ai/code/session_01HyTAyASedjizTRN7sTbw4W

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 29, 2026
@vercel

vercel Bot commented Jul 29, 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 Jul 29, 2026 8:41pm

Request Review

@dosubot dosubot Bot added the Feature Request New feature or request label Jul 29, 2026
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

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: ef81cdb2-0425-40d1-ac15-ca1274a37ee7

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
📝 Walkthrough

Walkthrough

Session reconstruction, last-message-only request reduction, and durable record persistence now default to enabled. The literal "false" disables each setting, with runtime tests and Docker environment examples updated accordingly.

Changes

Session behavior defaults

Layer / File(s) Summary
History flag semantics
web/packages/agenta-shared/src/api/env.ts, services/runner/src/engines/sandbox_agent/*, web/packages/agenta-playground/..., services/runner/tests/...
Client and server history flags now treat absent or empty values as enabled; tests cover explicit "false", empty, and absent values.
Durable persistence defaults
services/runner/src/sessions/persist.ts, services/runner/tests/unit/session-persist.test.ts
Durable record handling is enabled unless AGENTA_RECORDS_DURABLE is "false"; tests cover absent and empty values.
Environment templates and guidance
hosting/docker-compose/{ee,oss}/*
Docker Compose comments and environment examples document default-on behavior and explicit "false" overrides for session-history settings.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant buildAgentRequest
  participant reconstructHistoryIfNeeded
  participant HistoryAPI
  Client->>buildAgentRequest: build last-message-only request
  buildAgentRequest->>reconstructHistoryIfNeeded: provide minimal history
  reconstructHistoryIfNeeded->>HistoryAPI: fetch history unless flag is "false"
  HistoryAPI-->>reconstructHistoryIfNeeded: return reconstructed history
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: enabling the session-storage rework by default.
Description check ✅ Passed The description is directly about the same session-storage default-on change and its related updates.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 60.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/sessions-flags-default-on

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.

@mmabrouk

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
web/packages/agenta-playground/tests/unit/agentRequest.test.ts (2)

186-187: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Avoid introducing any in the runtime-env helper.

The new globalThis as any cast bypasses type checking in a workspace package. Define a typed __env shape instead.

Proposed fix
+type TestRuntimeGlobal = typeof globalThis & {
+    __env?: Record<string, string>
+}
+
         const setFlag = (value: string) => {
-            ;(globalThis as any).__env = {NEXT_PUBLIC_SESSIONS_LAST_MESSAGE_ONLY: value}
+            ;(globalThis as TestRuntimeGlobal).__env = {
+                NEXT_PUBLIC_SESSIONS_LAST_MESSAGE_ONLY: value,
+            }
         }

As per coding guidelines, workspace packages should avoid any and legacy compatibility shims.

Source: Coding guidelines


199-216: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover trimmed, case-insensitive "false" values.

The parser contract is case-insensitive and trims whitespace, but these tests only exercise exact values. Add a case such as " FALSE " to prevent regressions in normalization.

Proposed test
+        it("treats trimmed, case-insensitive false as disabled", async () => {
+            setFlag(" FALSE ")
+            expect(await outMessages([u1, a1, u2])).toEqual([u1, a1, u2])
+        })

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2deb58c2-e7aa-4f85-bd6e-5e17e66e2201

📥 Commits

Reviewing files that changed from the base of the PR and between 8df188b and 771cd87.

📒 Files selected for processing (17)
  • hosting/docker-compose/ee/docker-compose.dev.yml
  • hosting/docker-compose/ee/docker-compose.gh.yml
  • hosting/docker-compose/ee/env.ee.dev.example
  • hosting/docker-compose/ee/env.ee.gh.example
  • hosting/docker-compose/oss/docker-compose.dev.yml
  • hosting/docker-compose/oss/docker-compose.gh.yml
  • hosting/docker-compose/oss/env.oss.dev.example
  • hosting/docker-compose/oss/env.oss.gh.example
  • services/runner/src/engines/sandbox_agent/reconstruct-history.ts
  • services/runner/src/engines/sandbox_agent/run-turn.ts
  • services/runner/src/sessions/persist.ts
  • services/runner/tests/setup/hermetic-env.ts
  • services/runner/tests/unit/session-persist.test.ts
  • services/runner/tests/unit/session-reconstruct-history.test.ts
  • web/packages/agenta-playground/src/state/execution/agentRequest.ts
  • web/packages/agenta-playground/tests/unit/agentRequest.test.ts
  • web/packages/agenta-shared/src/api/env.ts

Comment on lines +90 to +97
* from the durable record log. ON unless set to the literal "false"; absent AND empty both mean
* on (compose passes `${VAR:-}`, which sets an empty string when unset). Disable it ONLY
* together with the backend `AGENTA_SESSIONS_RECONSTRUCT=false`, or a cold turn loses its
* context.
*/
export const isSessionsLastMessageOnlyEnabled = (): boolean => {
const raw = getEnv("NEXT_PUBLIC_SESSIONS_LAST_MESSAGE_ONLY") || "false"
return SANDBOX_LOCAL_TRUTHY.has(raw.trim().toLowerCase())
const raw = getEnv("NEXT_PUBLIC_SESSIONS_LAST_MESSAGE_ONLY")
return raw.trim().toLowerCase() !== "false"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Preserve explicitly empty runtime overrides.

The new default-on behavior is correct only if getEnv returns the runtime value. However, Line 52 treats runtimeEnv[envKey] as a truthy presence check, so __env.NEXT_PUBLIC_SESSIONS_LAST_MESSAGE_ONLY = "" falls back to build-time processEnv. A build produced with "false" will therefore remain disabled despite the documented empty-value default.

Use an own-property check so absent and explicitly empty values remain distinct.

Proposed fix
-    if (runtimeEnv && Object.keys(runtimeEnv).length > 0 && runtimeEnv[envKey]) {
+    if (
+        runtimeEnv &&
+        Object.keys(runtimeEnv).length > 0 &&
+        Object.prototype.hasOwnProperty.call(runtimeEnv, envKey)
+    ) {

mmabrouk added 2 commits July 29, 2026 22:23
AGENTA_SESSIONS_RECONSTRUCT, AGENTA_RECORDS_DURABLE, and
NEXT_PUBLIC_SESSIONS_LAST_MESSAGE_ONLY now read as enabled unless set to the
literal "false". Absent and empty both mean on, because the compose files pass
the vars through as ${VAR:-}, which materializes an empty string that overrides
env_file values.
@mmabrouk
mmabrouk force-pushed the feat/sessions-flags-default-on branch from 771cd87 to 15ed54d Compare July 29, 2026 20:39
@mmabrouk mmabrouk added the needs-review Agent updated; awaiting Mahmoud's review label Jul 29, 2026
@mmabrouk

Copy link
Copy Markdown
Member Author

🤖 The AI agent says:

Addressed all three review comments in commit 15ed54d:

  • Runtime environment overrides now use an own-property check, so an explicit empty value overrides a build-time false value as documented.
  • The test runtime global now has a typed __env shape instead of the new any cast.
  • The session flag tests now cover trimmed, case-insensitive false values. The empty-value test also simulates a build-time false value so it guards the reported deployment case.

Verified with the focused agentRequest suite (39 tests), package build and lint for @agenta/shared and @agenta/playground, and the repository frontend lint-fix pass.

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Preview URL https://gateway-production-5238.up.railway.app/w
Project agenta-oss-pr-5560
Image tag pr-5560-d4a866c
Status Deployed
Railway logs Open logs
Workflow logs View workflow run
Updated at 2026-07-30T09:55:41.822Z

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature Request New feature or request needs-review Agent updated; awaiting Mahmoud's review size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant