Skip to content

fix: add UUID guard for --resume in ClaudeAgentService#1064

Open
kaverjody wants to merge 1 commit into
zts212653:mainfrom
kaverjody:fix/claude-agent-service-uuid-resume-guard
Open

fix: add UUID guard for --resume in ClaudeAgentService#1064
kaverjody wants to merge 1 commit into
zts212653:mainfrom
kaverjody:fix/claude-agent-service-uuid-resume-guard

Conversation

@kaverjody

Copy link
Copy Markdown

Description

Fixes #1063

ClaudeAgentService was passing non-UUID sessionIds (e.g. catagent-<ts>-<random> from CatAgentService) directly to claude --resume, which Claude CLI rejects.

ClaudeBgCarrierService already had the correct UUID guard — this fix brings ClaudeAgentService in line.

Changes

  • ClaudeAgentService.ts: Added UUID_PATTERN guard before --resume. Non-UUID sessionIds skip resume and start fresh.
  • Tests: Updated existing test to use valid UUID; added new test verifying non-UUID is skipped.

Testing

54/55 tests pass (1 pre-existing env config issue unrelated).

ClaudeAgentService passes non-UUID sessionId (e.g. catagent-<ts>-<random>
from CatAgentService) directly to claude --resume, which rejects with:
  Error: --resume requires a valid session ID or session title
  when used with --print

Root cause: ClaudeAgentService.ts:369-371 lacked the UUID_PATTERN
guard that ClaudeBgCarrierService.ts:276 already has.

Fix:
- Export UUID_PATTERN from ClaudeAgentService.ts
- Guard --resume with UUID_PATTERN.test(options.sessionId)
- Update tests: existing test uses valid UUID; new test verifies
  non-UUID sessionId skips --resume entirely

Fixes zts212653#1063

Co-Authored-By: Claude <noreply@anthropic.com>
@kaverjody kaverjody requested a review from zts212653 as a code owner July 2, 2026 08:14
@zts212653 zts212653 added bug Something isn't working triaged Maintainer reviewed, replied, and made an initial triage decision accepted Maintainer accepted: ready for implementation/merge labels Jul 2, 2026
@zts212653

Copy link
Copy Markdown
Owner

👋 @kaverjody — 感谢首次贡献 + 完整分析!Direction 已 accepted(关联 issue #1063),代码走向合理(复用现有 UUID_PATTERN 是正确做法)。

Triage verdict: ✅ Accepted (with 2 pre-review blockers)

在正式 code review 之前有两件事需要清理:

Blocker 1: mergeStateStatus=BEHIND — 需要 rebase

你的 branch fix/claude-agent-service-uuid-resume-guard 落后 main。请 rebase 或 GitHub 上 Update branch,避免 review 后 merge 阶段又要处理 conflict。

Blocker 2: CI 未触发(FIRST_TIME_CONTRIBUTOR gate)

GitHub Actions 对 first-time contributor 的 PR 默认 action_required,需要 maintainer 手动 approve 才跑 workflow。maintainer 侧会 approve 让 CI 跑起来 — 你不用改任何东西。看到 CI 结果后(尤其是 Test (Windows) + Test (Public))我们再进 review-existing-pr。

Pre-review Scope 声明

Review 会 focus 三点(提前预告避免 surprise):

  1. UUID_PATTERN 是否已从 ClaudeBgCarrierService.ts export(避免常量复制形成 drift)
  2. 新增 test case 是否覆盖 non-UUID → fresh-start fallback 的实际行为,不只是断言 args 数组
  3. catagent-<ts>-<random> 之外的 legacy shortId (daemonShortId 8-hex form) 是否也会被这个 guard 正确 skip

Labels: bug / triaged / accepted。CI action_required 我们会 approve — 敬请等 CI 全绿后 ping。

[宪宪/claude-opus-4-7🐾] — inbound maintainer triage

@zts212653

Copy link
Copy Markdown
Owner

📝 Follow-up — scope discussion(同步于 #1063 comment)

Maintainer 讨论后收敛的定位:你的 PR 保留价值作为 defensive layer,但不能被当成 root fix

你 fix 的 scope 边界

Coverage:Claude Code 提供的 --resume 端 UUID guard
Non-coverage:其他 provider(Codex / OpenCode / Gemini / Kimi)在 cross-provider 切换时对上一个 provider 的 sessionId 会同样报错

举例:

  • 用户在 thread 里配了 Claude Code → 换成 Codex → session chain 里 UUID 交给 Codex CLI → Codex 说"我不认识 UUID 格式"
  • 你的 PR 修不了这条链路

建议 review body 加两句 acknowledgment

我们后续 review 时会 push back 建议你在 PR body 加一段 scope 声明:

Scope: this PR is Claude-CLI-side defensive guard. Cross-provider session mismatch (e.g. UUID from Claude passed to Codex CLI) is a broader session-chain concern tracked in a maintainer architectural issue — this PR is not the root fix.

这样将来 reviewer / 后续贡献者 grep 到 UUID_PATTERN.test 时能知道"这是 defensive belt-and-suspenders,root fix 在 chain 层"。

状态

  • 你的两个 blocker 仍然有效(rebase BEHIND + CI action_required maintainer approve
  • 加上一个新 request:PR body scope 声明段
  • Direction 依然 accepted,做完这三件后我们进 review

Labels 保持 bug + triaged + accepted

[宪宪/claude-opus-4-7🐾]

@zts212653

Copy link
Copy Markdown
Owner

📬 heads-up: 在 #1063 上留了一条邀请,看你有没有兴趣考虑更大的 scope(session chain 层 architectural fix)。三个选项,选哪个都 valid。链接:#1063 (comment)

(如果你就想留 narrow #1064 的 scope 也完全 fine,不会因此 downgrade PR review。)

[宪宪/claude-opus-4-7🐾]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accepted Maintainer accepted: ready for implementation/merge bug Something isn't working triaged Maintainer reviewed, replied, and made an initial triage decision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClaudeAgentService passes non-UUID sessionId to --resume, causing claude CLI error

2 participants