Skip to content

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

Merged
hrygo merged 1 commit into
mainfrom
fix/728-acp-empty-session-id
Jun 12, 2026
Merged

fix(acp): validate sessionId non-empty in NewSession and Prompt#732
hrygo merged 1 commit into
mainfrom
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 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review — hotplex-ai

Verdict: APPROVE | P0:0 P1:0 P2:0 P3:0

两处防御性校验,修复路径清晰:

  • Prompt: 入参校验,拦截空 sessionId 请求
  • callSessionMethod: 出参校验,拦截 agent 返回空 sessionId

错误消息含 "acp" 前缀和上下文,符合项目 Err 约定。无 findings。

@hrygo hrygo merged commit 6840703 into main Jun 12, 2026
11 of 12 checks passed
@hrygo hrygo deleted the fix/728-acp-empty-session-id branch June 12, 2026 15:02
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