Skip to content

feat(llc): claude_code adapter — ClaudeCodeAdapter for heartbeat sessions (#8258) - #8530

Merged
mrveiss merged 4 commits into
Dev_new_guifrom
issue-8258
May 24, 2026
Merged

mrveiss merged 4 commits into
Dev_new_guifrom
issue-8258

Conversation

@mrveiss

@mrveiss mrveiss commented May 24, 2026

Copy link
Copy Markdown
Owner

Summary

Implements GH#8258 — the claude_code adapter type for the LLC adapter registry, enabling agents to run Claude Code CLI sessions as their heartbeat execution vehicle.

What's included

  • claude_code_adapter.py — ClaudeCodeAdapter implementing invoke / status / cancel
    • invoke: launches claude CLI subprocess with --output-format stream-json; supports fat-context mode (RAG brief as prompt) and thin-context mode (task_id + API URL); passes --model, --max-turns, --allowedTools from adapter_config
    • status: reads state file for PID + timeout; probes with kill(pid, 0) for liveness; returns RUNNING / COMPLETED / FAILED / TIMEOUT
    • cancel: SIGTERM → probe loop → SIGKILL; clears Redis session on termination
  • Session continuity: session ID stored in Redis llc:agent:{id}:claude_session with 4h TTL; --resume {session_id} used on subsequent heartbeats
  • Output capture: stdout → /tmp/llc_agent_{agent_id}_{run_id}.jsonl for KB indexer pickup; state file written alongside
  • Error safety: all adapter errors caught; never propagates raw exceptions to caller — always returns AdapterRunStatus
  • Registry: ClaudeCodeAdapter() registered under "claude_code" in adapters/__init__.py
  • Tests: test_claude_code_adapter.py — invoke/status/cancel with mock subprocess + Redis, protocol conformance, registry check

Test plan

  • Syntax: python3 -m py_compile autobot-backend/llc/adapters/claude_code_adapter.py ✅
  • Test syntax: python3 -m py_compile autobot-backend/llc/adapters/tests/test_claude_code_adapter.py ✅
  • Registry check: from llc.adapters import get_adapter; get_adapter("claude_code") returns ClaudeCodeAdapter
  • CI smoke tests

Closes #8258

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented May 24, 2026 •

Copy link
Copy Markdown
Contributor

✅ SSOT Configuration Compliance: Passing

🎉 No hardcoded values detected that have SSOT config equivalents!

mrveiss and others added 4 commits May 24, 2026 19:56
…ions (#8258)

Implements the claude_code adapter type in the LLC adapter registry. The
adapter launches Claude Code CLI subprocesses as agent heartbeat execution
vehicles with full session continuity via Redis.

- ClaudeCodeAdapter (invoke/status/cancel) registered under "claude_code"
- invoke: spawns claude CLI with --output-format stream-json; fat context
  (rag_brief) or thin context (task_id + api_base_url) prompt modes;
  --allowedTools, --model, --max-turns from adapter_config
- Session continuity: session ID stored in Redis llc:agent:{id}:claude_session
  with 4h TTL; --resume used on subsequent heartbeats
- status: reads state file for PID + timeout check; probes pid 0 for liveness
- cancel: SIGTERM → probe loop → SIGKILL; clears Redis session on cancel
- Output captured to /tmp/llc_agent_{agent_id}_{run_id}.jsonl for KB indexer
- All adapter errors caught and returned as AdapterRunStatus.failed
- Unit tests: invoke/status/cancel with mock subprocess + Redis

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Paperclip <noreply@paperclip.ing>
@mrveiss
mrveiss merged commit f9331f0 into Dev_new_gui May 24, 2026
1 of 7 checks passed
@mrveiss
mrveiss deleted the issue-8258 branch May 24, 2026 16:56
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