Skip to content

Commit 9ac0c55

Browse files
authored
Merge pull request #5560 from Agenta-AI/feat/sessions-flags-default-on
feat: turn the session-storage rework on by default
2 parents 3d0cd6a + 15ed54d commit 9ac0c55

17 files changed

Lines changed: 178 additions & 80 deletions

File tree

hosting/docker-compose/ee/docker-compose.dev.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,10 @@ services:
431431
AGENTA_RUNNER_DAYTONA_SESSION_MAX_WARM: ${AGENTA_RUNNER_DAYTONA_SESSION_MAX_WARM:-}
432432
AGENTA_RUNNER_DAYTONA_AUTODELETE_MINUTES: ${AGENTA_RUNNER_DAYTONA_AUTODELETE_MINUTES:-}
433433
# This service has no env_file (see above), so the session flags must be listed
434-
# here or they can never be set. AGENTA_SESSIONS_RECONSTRUCT must be enabled
435-
# together with the web NEXT_PUBLIC_SESSIONS_LAST_MESSAGE_ONLY, or a turn that
436-
# carries only its last message loses the conversation.
434+
# here or they can never be set. Both default ON: absent or empty means on, and
435+
# only the literal "false" disables. Disable AGENTA_SESSIONS_RECONSTRUCT together
436+
# with the web NEXT_PUBLIC_SESSIONS_LAST_MESSAGE_ONLY, or a turn that carries
437+
# only its last message loses the conversation.
437438
AGENTA_SESSIONS_RECONSTRUCT: ${AGENTA_SESSIONS_RECONSTRUCT:-}
438439
AGENTA_RECORDS_DURABLE: ${AGENTA_RECORDS_DURABLE:-}
439440
# === STORAGE ============================================== #

hosting/docker-compose/ee/docker-compose.gh.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,10 @@ services:
303303
AGENTA_RUNNER_DAYTONA_SESSION_MAX_WARM: ${AGENTA_RUNNER_DAYTONA_SESSION_MAX_WARM:-}
304304
AGENTA_RUNNER_DAYTONA_AUTODELETE_MINUTES: ${AGENTA_RUNNER_DAYTONA_AUTODELETE_MINUTES:-}
305305
# This service has no env_file (see above), so the session flags must be listed
306-
# here or they can never be set. AGENTA_SESSIONS_RECONSTRUCT must be enabled
307-
# together with the web NEXT_PUBLIC_SESSIONS_LAST_MESSAGE_ONLY, or a turn that
308-
# carries only its last message loses the conversation.
306+
# here or they can never be set. Both default ON: absent or empty means on, and
307+
# only the literal "false" disables. Disable AGENTA_SESSIONS_RECONSTRUCT together
308+
# with the web NEXT_PUBLIC_SESSIONS_LAST_MESSAGE_ONLY, or a turn that carries
309+
# only its last message loses the conversation.
309310
AGENTA_SESSIONS_RECONSTRUCT: ${AGENTA_SESSIONS_RECONSTRUCT:-}
310311
AGENTA_RECORDS_DURABLE: ${AGENTA_RECORDS_DURABLE:-}
311312
# === SUBSCRIPTION MOUNTS (opt-in) ========================= #

hosting/docker-compose/ee/env.ee.dev.example

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,17 @@ AGENTA_RUNNER_DEFAULT_SANDBOX_PROVIDER=local
111111
# 5 min per tool call.
112112
# AGENTA_RUNNER_TOOL_CALL_TIMEOUT_MS=300000
113113

114-
# --- Session history: last-message-only turns (all four default off) ---
114+
# --- Session history: last-message-only turns ---
115115
# The client sends only the newest user message and the runner rebuilds the earlier turns
116116
# from the durable session record log, which keeps requests and traces small on a long
117-
# conversation. The first two must be flipped together: with the web flag on and the runner
118-
# flag off, a turn arrives with no history at all.
119-
# AGENTA_SESSIONS_RECONSTRUCT=true
120-
# NEXT_PUBLIC_SESSIONS_LAST_MESSAGE_ONLY=true
121-
# Records become the only copy of the conversation, so make writing them durable and keep
122-
# the structure of a record whose body exceeds the API size cap.
123-
# AGENTA_RECORDS_DURABLE=true
117+
# conversation. The three flags below default ON (absent or empty means on); set the
118+
# literal "false" to disable. Disable the first two together: with the web flag on and
119+
# the runner flag off, a turn arrives with no history at all.
120+
# AGENTA_SESSIONS_RECONSTRUCT=false
121+
# NEXT_PUBLIC_SESSIONS_LAST_MESSAGE_ONLY=false
122+
# AGENTA_RECORDS_DURABLE=false
123+
# Smart truncation preserves the structure of a record whose body exceeds the API size
124+
# cap (higher-fidelity reconstruction). Still opt-in, default off.
124125
# AGENTA_RECORDS_SMART_TRUNCATION=true
125126

126127
# ================================================================== #

hosting/docker-compose/ee/env.ee.gh.example

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,17 @@ AGENTA_RUNNER_TOKEN=replace-me
113113
# 5 min per tool call.
114114
# AGENTA_RUNNER_TOOL_CALL_TIMEOUT_MS=300000
115115

116-
# --- Session history: last-message-only turns (all four default off) ---
116+
# --- Session history: last-message-only turns ---
117117
# The client sends only the newest user message and the runner rebuilds the earlier turns
118118
# from the durable session record log, which keeps requests and traces small on a long
119-
# conversation. The first two must be flipped together: with the web flag on and the runner
120-
# flag off, a turn arrives with no history at all.
121-
# AGENTA_SESSIONS_RECONSTRUCT=true
122-
# NEXT_PUBLIC_SESSIONS_LAST_MESSAGE_ONLY=true
123-
# Records become the only copy of the conversation, so make writing them durable and keep
124-
# the structure of a record whose body exceeds the API size cap.
125-
# AGENTA_RECORDS_DURABLE=true
119+
# conversation. The three flags below default ON (absent or empty means on); set the
120+
# literal "false" to disable. Disable the first two together: with the web flag on and
121+
# the runner flag off, a turn arrives with no history at all.
122+
# AGENTA_SESSIONS_RECONSTRUCT=false
123+
# NEXT_PUBLIC_SESSIONS_LAST_MESSAGE_ONLY=false
124+
# AGENTA_RECORDS_DURABLE=false
125+
# Smart truncation preserves the structure of a record whose body exceeds the API size
126+
# cap (higher-fidelity reconstruction). Still opt-in, default off.
126127
# AGENTA_RECORDS_SMART_TRUNCATION=true
127128

128129
# ================================================================== #

hosting/docker-compose/oss/docker-compose.dev.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,10 @@ services:
417417
AGENTA_RUNNER_DAYTONA_SESSION_MAX_WARM: ${AGENTA_RUNNER_DAYTONA_SESSION_MAX_WARM:-}
418418
AGENTA_RUNNER_DAYTONA_AUTODELETE_MINUTES: ${AGENTA_RUNNER_DAYTONA_AUTODELETE_MINUTES:-}
419419
# This service has no env_file (see above), so the session flags must be listed
420-
# here or they can never be set. AGENTA_SESSIONS_RECONSTRUCT must be enabled
421-
# together with the web NEXT_PUBLIC_SESSIONS_LAST_MESSAGE_ONLY, or a turn that
422-
# carries only its last message loses the conversation.
420+
# here or they can never be set. Both default ON: absent or empty means on, and
421+
# only the literal "false" disables. Disable AGENTA_SESSIONS_RECONSTRUCT together
422+
# with the web NEXT_PUBLIC_SESSIONS_LAST_MESSAGE_ONLY, or a turn that carries
423+
# only its last message loses the conversation.
423424
AGENTA_SESSIONS_RECONSTRUCT: ${AGENTA_SESSIONS_RECONSTRUCT:-}
424425
AGENTA_RECORDS_DURABLE: ${AGENTA_RECORDS_DURABLE:-}
425426
# === STORAGE ============================================== #

hosting/docker-compose/oss/docker-compose.gh.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,10 @@ services:
320320
AGENTA_RUNNER_DAYTONA_SESSION_MAX_WARM: ${AGENTA_RUNNER_DAYTONA_SESSION_MAX_WARM:-}
321321
AGENTA_RUNNER_DAYTONA_AUTODELETE_MINUTES: ${AGENTA_RUNNER_DAYTONA_AUTODELETE_MINUTES:-}
322322
# This service has no env_file (see above), so the session flags must be listed
323-
# here or they can never be set. AGENTA_SESSIONS_RECONSTRUCT must be enabled
324-
# together with the web NEXT_PUBLIC_SESSIONS_LAST_MESSAGE_ONLY, or a turn that
325-
# carries only its last message loses the conversation.
323+
# here or they can never be set. Both default ON: absent or empty means on, and
324+
# only the literal "false" disables. Disable AGENTA_SESSIONS_RECONSTRUCT together
325+
# with the web NEXT_PUBLIC_SESSIONS_LAST_MESSAGE_ONLY, or a turn that carries
326+
# only its last message loses the conversation.
326327
AGENTA_SESSIONS_RECONSTRUCT: ${AGENTA_SESSIONS_RECONSTRUCT:-}
327328
AGENTA_RECORDS_DURABLE: ${AGENTA_RECORDS_DURABLE:-}
328329
# === SUBSCRIPTION MOUNTS (opt-in) ========================= #

hosting/docker-compose/oss/env.oss.dev.example

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,17 @@ AGENTA_RUNNER_DEFAULT_SANDBOX_PROVIDER=local
111111
# 5 min per tool call.
112112
# AGENTA_RUNNER_TOOL_CALL_TIMEOUT_MS=300000
113113

114-
# --- Session history: last-message-only turns (all four default off) ---
114+
# --- Session history: last-message-only turns ---
115115
# The client sends only the newest user message and the runner rebuilds the earlier turns
116116
# from the durable session record log, which keeps requests and traces small on a long
117-
# conversation. The first two must be flipped together: with the web flag on and the runner
118-
# flag off, a turn arrives with no history at all.
119-
# AGENTA_SESSIONS_RECONSTRUCT=true
120-
# NEXT_PUBLIC_SESSIONS_LAST_MESSAGE_ONLY=true
121-
# Records become the only copy of the conversation, so make writing them durable and keep
122-
# the structure of a record whose body exceeds the API size cap.
123-
# AGENTA_RECORDS_DURABLE=true
117+
# conversation. The three flags below default ON (absent or empty means on); set the
118+
# literal "false" to disable. Disable the first two together: with the web flag on and
119+
# the runner flag off, a turn arrives with no history at all.
120+
# AGENTA_SESSIONS_RECONSTRUCT=false
121+
# NEXT_PUBLIC_SESSIONS_LAST_MESSAGE_ONLY=false
122+
# AGENTA_RECORDS_DURABLE=false
123+
# Smart truncation preserves the structure of a record whose body exceeds the API size
124+
# cap (higher-fidelity reconstruction). Still opt-in, default off.
124125
# AGENTA_RECORDS_SMART_TRUNCATION=true
125126

126127
# ================================================================== #

hosting/docker-compose/oss/env.oss.gh.example

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,17 @@ AGENTA_RUNNER_TOKEN=replace-me
113113
# 5 min per tool call.
114114
# AGENTA_RUNNER_TOOL_CALL_TIMEOUT_MS=300000
115115

116-
# --- Session history: last-message-only turns (all four default off) ---
116+
# --- Session history: last-message-only turns ---
117117
# The client sends only the newest user message and the runner rebuilds the earlier turns
118118
# from the durable session record log, which keeps requests and traces small on a long
119-
# conversation. The first two must be flipped together: with the web flag on and the runner
120-
# flag off, a turn arrives with no history at all.
121-
# AGENTA_SESSIONS_RECONSTRUCT=true
122-
# NEXT_PUBLIC_SESSIONS_LAST_MESSAGE_ONLY=true
123-
# Records become the only copy of the conversation, so make writing them durable and keep
124-
# the structure of a record whose body exceeds the API size cap.
125-
# AGENTA_RECORDS_DURABLE=true
119+
# conversation. The three flags below default ON (absent or empty means on); set the
120+
# literal "false" to disable. Disable the first two together: with the web flag on and
121+
# the runner flag off, a turn arrives with no history at all.
122+
# AGENTA_SESSIONS_RECONSTRUCT=false
123+
# NEXT_PUBLIC_SESSIONS_LAST_MESSAGE_ONLY=false
124+
# AGENTA_RECORDS_DURABLE=false
125+
# Smart truncation preserves the structure of a record whose body exceeds the API size
126+
# cap (higher-fidelity reconstruction). Still opt-in, default off.
126127
# AGENTA_RECORDS_SMART_TRUNCATION=true
127128

128129
# ================================================================== #

services/runner/src/engines/sandbox_agent/reconstruct-history.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
* Seam that lets the runner rebuild prior conversation from the durable record log instead of
33
* trusting a full inbound history — the server side of "client sends only the last message".
44
*
5-
* Flag-gated (`AGENTA_SESSIONS_RECONSTRUCT`) and a strict no-op until BOTH the flag is on AND the
6-
* client actually sent a minimal history (`carriesMinimalHistory`). When it does not apply, the
7-
* inbound history is left untouched.
5+
* Flag-gated (`AGENTA_SESSIONS_RECONSTRUCT`, ON unless set to the literal "false") and a strict
6+
* no-op until BOTH the flag is on AND the client actually sent a minimal history
7+
* (`carriesMinimalHistory`). When it does not apply, the inbound history is left untouched.
88
*
99
* When it DOES apply it is no longer best-effort, because the client kept no copy of the
1010
* conversation: an unreadable log, or one known to have dropped a record, fails the turn rather
@@ -22,9 +22,11 @@ import { recordsIncomplete } from "../../sessions/persist.ts";
2222
import { reconstructMessages } from "../../sessions/reconstruct.ts";
2323
import { carriesMinimalHistory } from "./session-identity.ts";
2424

25+
// ON unless the literal "false"; absent AND empty both mean on (compose passes `${VAR:-}`,
26+
// which sets an empty string when the shell has no value).
2527
function reconstructEnabled(): boolean {
2628
return (
27-
String(process.env.AGENTA_SESSIONS_RECONSTRUCT ?? "").toLowerCase() === "true"
29+
String(process.env.AGENTA_SESSIONS_RECONSTRUCT ?? "").trim().toLowerCase() !== "false"
2830
);
2931
}
3032

services/runner/src/engines/sandbox_agent/run-turn.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ export async function runTurn(
150150
});
151151

152152
try {
153-
// Server-side history reconstruction (flag-gated, no-op by default): when the client sent a
154-
// minimal history, rebuild prior turns from the durable record log so a cold turn still has
155-
// full context. Runs before the current user turn is persisted, so records hold only prior
156-
// turns. Reassigns `request` so every downstream reader (turnText, priorMessages, responder,
157-
// otel) sees the same reconstructed history.
153+
// Server-side history reconstruction (on by default; AGENTA_SESSIONS_RECONSTRUCT=false
154+
// disables): when the client sent a minimal history, rebuild prior turns from the durable
155+
// record log so a cold turn still has full context. Runs before the current user turn is
156+
// persisted, so records hold only prior turns. Reassigns `request` so every downstream
157+
// reader (turnText, priorMessages, responder, otel) sees the same reconstructed history.
158158
const reconstructed = await reconstructHistoryIfNeeded(
159159
request,
160160
sessionId,

0 commit comments

Comments
 (0)