Skip to content

fix(acp): Gemini ACP protocol fixes and multi-session architecture#901

Open
codebit0 wants to merge 4 commits intonextlevelbuilder:devfrom
codebit0:fix/acp-protocol-standard
Open

fix(acp): Gemini ACP protocol fixes and multi-session architecture#901
codebit0 wants to merge 4 commits intonextlevelbuilder:devfrom
codebit0:fix/acp-protocol-standard

Conversation

@codebit0
Copy link
Copy Markdown

Summary

  • Rework ACP provider to support multiple concurrent sessions on a single shared Gemini subprocess (one process per pool key, one ACP session per goclaw conversation)
  • Add per-key mutex in resolveSession to prevent TOCTOU race on concurrent session creation for the same conversation
  • Add respawn detection via proc pointer comparison; fall back to session/load after process crash, then session/new
  • Purge temp- sessions (used by intent_classify, title_generate) immediately after completion instead of waiting for the 30-minute idle reaper
  • Propagate goclaw session key through context (WithGoclawSession) so ACP-level logs show both goclaw session and ACP session ID side by side
  • Map Gemini agent_message_chunk notifications in dispatchUpdate to normalize protocol differences at the process layer
  • Fix InitializeRequest field name: "capabilities""clientCapabilities" (ACP SDK v0.16.1 standard)
  • Add mcpServers field to LoadSessionRequest (required by standard)
  • Add standard stop reasons (max_tokens, cancelled) to mapStopReason
  • Allow Google/GCP env vars to pass through to ACP subprocesses (required for Gemini auth)
  • Fix missing X-GoClaw-User-Id header in gateway client

Changed files

  • internal/providers/acp/process.go — multi-session routing via updateFns map, dispatchUpdate, ProcessPool
  • internal/providers/acp/session.goInitialize, NewSession, LoadSession, Prompt, Cancel
  • internal/providers/acp/types.goclientCapabilities field name, LoadSessionRequest.McpServers
  • internal/providers/acp_provider.goresolveSession, sessionReaper, purgeSession, Chat, ChatStream
  • internal/providers/acp/helpers.goWithGoclawSession / goclawSessionFromCtx
  • internal/providers/acp/session_test.go — multi-session API coverage
  • internal/providers/acp/acp_gemini_test.go — live Gemini protocol integration test

codebit0 and others added 4 commits April 12, 2026 11:54
- Support nested JSON-RPC notification structures
- Add robust streaming text collection and mapping
- Increase handshake timeout to 60s for heavy model initialization
- Fix WebSocket user_id authentication and schema v47 compatibility
- Allow Google/GCP environment variables for ACP subprocesses
…mp session cleanup

- One shared Gemini process, multiple ACP sessions per process (one per goclaw conversation)
- resolveSession: per-key mutex prevents TOCTOU race on concurrent session creation
- Respawn detection via proc pointer comparison; session/load fallback after crash
- sessionReaper: purges ACP sessions idle >30min; temp- sessions purged immediately on completion
- WithGoclawSession context propagation: goclaw session key appears alongside ACP sid in all logs
- dispatchUpdate: Gemini agent_message_chunk protocol mapping normalized here
- session_test.go: full coverage of multi-session API (Initialize, NewSession, Prompt, Cancel, dispatch)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- InitializeRequest: "capabilities" → "clientCapabilities" (standard field name)
- LoadSessionRequest: add mcpServers field (required by standard)
- mapStopReason: add standard stop reasons (max_tokens, cancelled)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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