Skip to content

Session tab — --resume-default chat surface for stateful conversations #651

Closed

Description

@webmixgamer

Summary

Adds a Session tab to the Agent Detail page that runs every turn through claude --print --resume <uuid>, preserving tool-result memory, mid-skill state, and reasoning state across messages. Strictly more capable than Chat's stateless text-replay model for long, multi-turn reasoning tasks.

Problem

Chat reconstructs context by replaying the visible message log to a fresh Claude process every turn. Tool outputs, mid-skill state, and Claude's internal reasoning don't survive between turns — agents re-derive everything they figured out previously, paying full token cost each time. Heavy multi-step skills (planning + multi-tool workflows) are particularly hurt by the lack of memory continuity.

Solution

A parallel surface to Chat — separate router, separate Pinia store, separate Vue component, separate DB tables. Each turn re-attaches to the same Claude Code session via --resume, so working memory persists. Chat is untouched. Schedules, MCP chat_with_agent, fan-out, and webhook triggers stay on text-replay (concurrency hazards make --resume unsafe there).

Key Components

  • New tables: agent_sessions, agent_session_messages (parallel to chat_sessions / chat_messages, with the load-bearing cached_claude_session_id field driving --resume).
  • Six new endpoints under /api/agents/{name}/sessions* (CRUD + the synchronous turn endpoint).
  • Per-(agent, claude_uuid) Redis lock to serialize concurrent resume turns (Anthropic #20992 corruption guard).
  • Resume-failure fallback: if a cached UUID's JSONL is missing on disk (Anthropic #39667 / #53417), clear the cache and retry cold once.
  • JSONL cleanup service — synchronous best-effort on user reset/delete + 6h periodic sweep with 1h race guard.
  • Auto-compact event capture — Claude Code's mid-turn auto-compact (~85% of model window) is captured from the JSONL post-turn and surfaced as a violet "compacted" badge in the Tasks tab plus an inline reset hint when a session has been compacted >5 times.
  • Stdout-pipe-race recovery: when a tool subprocess wedges the agent server's stdout reader, the agent server reads the JSONL on disk and synthesizes a soft-success response instead of failing 502.
  • MCP validator allowance: the RESERVED_SERVER_NAMES = {"trinity"} rule (defense against attacker-controlled redefinition) special-cases the canonical Trinity-MCP shape so owners can rotate their bearer token without tripping the reserved-name reject.

Documentation

  • Design: docs/planning/SESSION_TAB_2026-04.md
  • Vertical-slice flow: docs/memory/feature-flows/session-tab.md
  • User guide: docs/user-docs/agents/agent-session.md

Feature flag

Default ON in the source (Phase 5.3 GA, 2026-05-04). Admins can opt out via system_settings.session_tab_enabled = false or SESSION_TAB_ENABLED=false env.

Testing

  • 25 unit tests for session DB ops + parser (system/init recognition, result fallback)
  • 11 unit tests for JSONL recovery (response + compact event extraction)
  • 102 unit tests for the MCP validator (including new canonical-trinity allowance)
  • Integration: 3-turn happy path, B's recall of A's secret, JSONL deletion → fallback, concurrent serialise via Redis lock, switching sessions preserves UUIDs, cross-session contamination, JSONL cleanup
  • E2E: Playwright spec src/frontend/e2e/session-tab.spec.js (@interactive — opt-in)
  • Manual probes: §5 of tests/manual/session-tab/README.md covers stdout-race, concurrency, agent-switch reload, subscription change mid-session (E7 verified non-issue 2026-05-04)

Acceptance criteria

  • Session tab appears next to Chat tab when feature flag is on
  • Each turn reattaches to the same Claude Code session UUID
  • Tool memory + reasoning state survives across turns
  • Reset memory clears the cached UUID + reaps JSONL
  • Per-user scope: owners cannot see other users' sessions
  • Auto-compact events captured + surfaced in Tasks tab
  • Inline reset hint when compact_count > 5
  • Validator allows canonical trinity entry through credentials Save flow
  • All test suites green

Related

  • Anthropic #20992 (concurrent --resume JSONL corruption) — mitigated via Redis lock
  • Anthropic #39667 / #53417 (cleanupPeriodDays / CLI upgrade missing JSONL) — mitigated via resume-failure fallback
  • Anthropic #26964 (cross-session contamination via shared cwd) — empirically not present on this Claude Code version (contamination test green)

Activity

  1. added
    priority-p1
    type-feature
    on May 4, 2026
  2. added a commit that references this issue on May 4, 2026
  3. added a commit that references this issue on May 5, 2026
    bdca9f2
  4. added
    status-in-dev
    on May 5, 2026
  5. added a commit that references this issue on Jun 1, 2026
    7b64bb4
  6. added
    complexity-medium
    theme-devex
    on Jun 3, 2026
  7. removed
    status-in-dev
    on Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-mediumpriority-p1theme-devextype-feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions