fix(acp): validate sessionId non-empty in NewSession and Prompt#731
Closed
hrygo wants to merge 1 commit into
Closed
fix(acp): validate sessionId non-empty in NewSession and Prompt#731hrygo wants to merge 1 commit into
hrygo wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)。修复
两处校验:
callSessionMethod— 校验SessionResult.SessionID非空,空值返回明确错误而非静默传播Prompt— 防御性校验空sessionID,避免发送无效 JSON-RPC 请求测试
go test -count=1 -race ./internal/worker/acp/✅