Skip to content

Comments

fix: CLI backend session resume + TUI output#1921

Merged
steipete merged 4 commits intoopenclaw:mainfrom
rmorse:fix/cli-backend-fixes
Jan 25, 2026
Merged

fix: CLI backend session resume + TUI output#1921
steipete merged 4 commits intoopenclaw:mainfrom
rmorse:fix/cli-backend-fixes

Conversation

@rmorse
Copy link
Contributor

@rmorse rmorse commented Jan 25, 2026

AI-Assisted

  • Code generated with Claude Code assistance
  • Testing: Fully tested (build, lint, unit tests, manual verification)
  • Changes understood and reviewed

Summary

  • Fix Claude CLI session resume not working through the gateway
  • Fix TUI showing "(no output)" for CLI backend responses

Problem 1: Session Resume

Claude CLI requires different flags for new vs resumed sessions:

  • New session: --session-id <id>
  • Resume session: --resume <id>

Without proper resumeArgs, follow-up messages would try to use --session-id with an existing session ID, causing:

Error: Session ID already in use

Two bugs prevented session continuity:

  1. DEFAULT_CLAUDE_BACKEND had no resumeArgs, so it always used --session-id
  2. Gateway's agent.ts wasn't copying cliSessionIds/claudeCliSessionId to nextEntry, so CLI session IDs were lost between requests

Problem 2: TUI "(no output)"

TUI uses WebSocket streaming events. Flow:

  • Streaming providers (API): emit evt.stream === "assistant" events → buffer populated → final message has text
  • CLI backends: no streaming → buffer stays empty → emitChatFinal sends undefined → TUI shows "(no output)"

Changes

Session Resume

  • src/agents/cli-backends.ts - Add resumeArgs to Claude backend
  • src/gateway/server-methods/agent.ts - Preserve CLI session ID fields in nextEntry
  • src/gateway/server-methods/agent.test.ts - Add regression test

TUI Output

  • src/auto-reply/reply/agent-runner-execution.ts - Emit assistant event with final text before lifecycle end for CLI backends

Test plan

  • pnpm build passes
  • pnpm lint passes
  • pnpm test passes (unrelated heartbeat test failures pre-existing)
  • Manual: session resume works - follow-up messages maintain conversation
  • Manual: TUI displays CLI backend responses correctly

@steipete steipete self-assigned this Jan 25, 2026
rmorse and others added 4 commits January 25, 2026 20:58
- Add resumeArgs to DEFAULT_CLAUDE_BACKEND for proper --resume flag usage
- Fix gateway not preserving cliSessionIds/claudeCliSessionId in nextEntry
- Add test for CLI session ID preservation in gateway agent handler
- Update docs with new resumeArgs default
CLI backends (claude-cli etc) don't emit streaming assistant events,
causing TUI to show "(no output)" despite correct processing. Now emits
assistant event with final text before lifecycle end so server-chat
buffer gets populated for WebSocket clients.
@steipete steipete force-pushed the fix/cli-backend-fixes branch from 769042d to c1b98ff Compare January 25, 2026 21:08
@steipete steipete merged commit e0adf65 into openclaw:main Jan 25, 2026
21 of 22 checks passed
@steipete
Copy link
Contributor

Landed via temp rebase onto main.

  • Gate: pnpm lint && pnpm build && pnpm test
  • Land commit: c1b98ff
  • Merge commit: e0adf65

Thanks @rmorse!

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.

2 participants