Skip to content

fix(sessions): pass task as a file, not a giant env var — unbreak the consolidator (v0.265.2)#463

Merged
vikasprogrammer merged 1 commit into
mainfrom
feat/consolidator-tmux-cmdlen
Jul 24, 2026
Merged

fix(sessions): pass task as a file, not a giant env var — unbreak the consolidator (v0.265.2)#463
vikasprogrammer merged 1 commit into
mainfrom
feat/consolidator-tmux-cmdlen

Conversation

@vikasprogrammer

Copy link
Copy Markdown
Owner

The bug

The consolidator (memory gardener) crashed at launch on every tenant — instapods, instawp, expresstech alike (5/5, 6/6, 4/4 over the last week). Each died ~11s in, turns=null, wrote its .company.md/.mcp.json but no transcript and no .log. The consolidation half of the self-learning loop has been silently dead while the Insights UI still read "Reflect ran" (the watermark advances at kickoff).

Root cause

LocalSessionBackend.spawn puts every launch env var on the tmux new-session command line, and tmux hard-caps that command at ~16KB — over it, new-session fails with command too long. The consolidator embeds up to 40 recent episodes/lessons in its task (18–46KB); base64'd into TASK_B64 it overflowed the cap, so new-session failed silently: no pane was ever created → no transcript, no .log → the liveness sweep flipped the never-launched running row to crashed.

The one consolidator run that ever succeeded had an 8KB task. Confirmed empirically: new-session succeeds at an 8KB inline env, fails at ≥20KB (command too long). Any chat/automation run with a prompt over ~10KB hit the same wall.

The uid-isolation launcher was never affected (it passes env via systemd-run --setenv, a 1MB ARG_MAX), which is why this only bit the local-mode fleet.

Fix

The task now rides as a file (TASK_FILE) — exactly like mcp.json/company.md already do — instead of a giant inline env var, keeping the new-session command line tiny regardless of task size:

  • launchClaudeCode writes session-<id>.task, sets TASK_FILE, and drops TASK_B64 from the launch env.
  • claude-launch.sh reads TASK_FILE, falling back to TASK_B64 for pre-existing resume envs.
  • The uid-isolation launcher writes the task into the member home and sets TASK_FILE too.

Verification

  • tmux new-session now succeeds with a 46KB task (old inline path failed >~16KB).
  • The real claude-launch.sh UNATTENDED lane reads a 20KB task from TASK_FILE; claude launches and ingests the full prompt (transcript written) — previously no pane/transcript ever formed.
  • npm run typecheck + npm run build + 102/102 governance conformance.

🤖 Generated with Claude Code

… consolidator + any large-prompt run (v0.265.2)

LocalSessionBackend inlines every launch env var onto the `tmux new-session`
command line, and tmux hard-caps that command at ~16KB ("command too long").
The consolidator embeds up to 40 episodes/lessons in its task (18–46KB); base64'd
into TASK_B64 it overflowed the cap, so new-session failed silently — no pane, no
transcript, no .log — and the liveness sweep flipped the never-launched row to
`crashed` (~11s, turns=null). Fleet-wide, every headless consolidator run crashed;
only the one small-task run had ever succeeded. Any chat/automation run with a
prompt over ~10KB hit the same wall.

Fix: the task rides as a file (TASK_FILE) like mcp.json/company.md already do, so
the command line stays tiny regardless of task size. claude-launch.sh reads
TASK_FILE and falls back to TASK_B64 for pre-existing resume envs. The uid-isolation
launcher writes the task into the member home and sets TASK_FILE too.

Verified: tmux new-session now succeeds with a 46KB task (previously failed >~16KB);
the real claude-launch.sh UNATTENDED lane reads a 20KB task from TASK_FILE and claude
launches + ingests it (transcript written). typecheck + build + 102/102 governance.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JVfxDWBcQLbAqJPshB4Ha2
@vikasprogrammer
vikasprogrammer merged commit 78c09d1 into main Jul 24, 2026
@vikasprogrammer
vikasprogrammer deleted the feat/consolidator-tmux-cmdlen branch July 24, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant