Skip to content

fix(acp): validate sessionId non-empty in NewSession and Prompt#731

Closed
hrygo wants to merge 1 commit into
mainfrom
worktree-fix+728-acp-empty-session-id
Closed

fix(acp): validate sessionId non-empty in NewSession and Prompt#731
hrygo wants to merge 1 commit into
mainfrom
worktree-fix+728-acp-empty-session-id

Conversation

@hrygo

@hrygo hrygo commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Resolves #728

根因

当 DB 中 worker_session_id 为空时(历史遗留 session,如 #710 修复前创建),ACP worker resume 路径调用 forceNewSession()NewSession()。如果 ACP agent 返回空 sessionId,空值静默传播到 Prompt(ctx, "", content),导致 hermes-agent 报 prompt: session not found(双空格),后续 turn 返回空回复(text_len=0)。

修复

两处校验:

  1. callSessionMethod — 校验 SessionResult.SessionID 非空,空值返回明确错误而非静默传播
  2. Prompt — 防御性校验空 sessionID,避免发送无效 JSON-RPC 请求

测试

  • go test -count=1 -race ./internal/worker/acp/
  • pre-push 质量门禁全通过(formatting, vet, mod verify, lint, build, tests)✅

When worker_session_id is empty in DB (e.g. sessions created before #710
persist fix), resume path calls forceNewSession → NewSession. If the ACP
agent returns an empty sessionId, it propagates silently to Prompt which
sends "sessionId":"" to the agent, causing "session not found" errors.

Add two guard checks:
- callSessionMethod: reject empty SessionID from agent
- Prompt: reject empty sessionID before sending request

Closes #728
@hrygo hrygo closed this Jun 12, 2026
@hrygo hrygo deleted the worktree-fix+728-acp-empty-session-id branch June 12, 2026 14:45
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.

fix(acp): prompt sends empty sessionId when worker_session_id is empty in DB

2 participants