fix(server): a Claude /goal no longer reads as complete while a background subagent runs#16598

merged4
main
GitHub fork: fix/claude-goal-background-subagent
openedOct 6, 2026byJJreevo
View on GitHubTwo-way sync enabledPR last imported 21d ago

Claude /goal could show complete when the root turn ended while a background subagent was still running. Claude defers its goal evaluation in that state, so clearing the goal from the UI could discard work that was still in progress.

Goal completion now also checks live subagent work using the existing process and buffered-completion guards. Provider task types stay on the existing subagent records: agent/workflow tasks defer completion, known exempt tasks do not, and an absent task type conservatively defers it. Completion still requires a subsequent normally completed goal-checking turn.

Credit to @Jreevo for the provider investigation and original fix in #16598. This maintainer takeover preserves the author's commits, merges current main, and replaces the separate exemption registry with existing subagent state. Fixes #16611.

Verification:

  • Reduced the PR's 4 added cases (216 lines) to 3 (132 lines) in ClaudeAdapterV2.test.ts: background lifecycle through eventual completion, exempt task, and absent task type. Against the exact main adapter, 2 cases fail with premature complete; the rebuilt adapter passes all 289 tests.
  • Scoped lint, server typecheck, formatting, and git diff --check pass. Lint retains one pre-existing unused layer warning.
  • Live Linux probe using the production adapter, real SDK 0.3.276, Claude Code 2.1.303, and Sonnet 5.5: root turn completed with a running review subagent and goal active; the subsequent background wake completed the goal. Sanitized live trace and regression evidence.
  • Full HTTP/WebSocket/client integration, macOS, Windows, Electron desktop, iOS, and Android were not verified. No UI code changed; the attachment records adapter state rather than rendered client evidence.

One independent full-diff review round by Claude Opus 5.5 and GPT-6-Sol found no code blockers at fc8188d549. Opus also confirmed the provider task-type list against Claude Code 2.1.303. The SDK does not expose every provider-internal idle/long-running task exclusion, so those rare cases may conservatively leave the goal active until a later turn.

Models: GPT-6-Astra (tests), GPT-6.1-Sol (implementation), Claude Opus 5.5 and GPT-6-Sol (review). Harnesses: Codex and Claude Code through T3 Code.

Checks

23 successful · 11 skipped
All checks passed
fc8188d
Synced from GitHub

Approvability

Verdict: Approved at fc8188d

Macroscope's review found this PR approvable — This is a focused Claude adapter bug fix that prevents goals from being marked complete while recognized background subagents are still running, with targeted lifecycle tests and no schema, deployment, default, or static-analysis changes. The runtime impact is confined to goal-status evaluation in the existing orchestration path.

You can add or adjust custom eligibility rules. Learn more.

Synced from GitHub

Review in Change Stack →

Warning

Review limit reached

Only developers with an assigned seat can use this organization's usage-based review budget, and seats here are assigned manually. Ask an admin to assign a seat, or change the review continuation mode in Billing.

Next included review available in 6 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ed9fc205-0df1-45f9-86b0-a596eed4643c
📥 Commits

Reviewing files that changed from the base of the PR and between 98d67c1aaafcde0b9ec501d3d75fe2680687f45b and fc8188d549728109237e0a1f612c900a0116d163.

📒 Files selected for processing: 2
  • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
  • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b8890b1a-3c7d-4038-9c6f-c76bd72f20bc
📥 Commits

Reviewing files that changed from the base of the PR and between c9f9a646c6da34e7c2a07a5b1dfdefc3cf266cc6 and 98d67c1aaafcde0b9ec501d3d75fe2680687f45b.

📒 Files selected for processing (2)
  • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
  • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📝 Walkthrough

Claude goal completion now checks active background work in the matching live query. Four task types defer the goal check. Other defined subagent task types do not block completion. Tests cover task launch, wake continuation, and expected goal statuses.

Changes: Claude goal completion

Layer / File(s)Summary
Track goal-exempt task types
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
Claude defines four task types that defer goal checks. It records IDs for started subagent tasks with other defined task types.
Apply task types to goal completion
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts, apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
Goal completion is blocked by active background work that defers goal checks. Tests cover a background Agent lifecycle and expected statuses for running task types.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix

Suggested reviewers: juliusmarminge

Merge Risk: ⚪ Minimal · up to 98d67

No actionable merge-blocking issue remains after normal checks.

Security architecture risk: ⚪ Minimal · up to 98d67

The change makes goal completion more conservative while background work runs. It does not add permissions, expose a new interface, or weaken the protection against replacing a process that still has active work.

Retained concerns No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated effect is on goal status projected onto the provider thread within an opened session. The new check is restricted to a matching native thread and does not grant tool authority or expand process-replacement eligibility.

Trust Boundaries and Controls

  • observed — Task classification consumes system lifecycle messages from the existing query-session stream. Existing goal tracking distinguishes root synthetic goal signals from ordinary assistant output, and query policy remains derived from the turn's runtime policy rather than task exemption state.
Pre-merge checks: Passed 5
Check nameStatusExplanation
Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
ApprovabilityPassedPASS. The pull request changes only ClaudeAdapterV2.ts and its test file. The adapter change is a focused fix to Claude goal-completion inference while background work runs. The test adds cases for …
Title checkPassedThe title clearly and concisely describes the primary fix: Claude /goal must remain active while a background subagent runs.
Description checkPassedThe description explains the problem, implementation, scope, linked issue, focused verification, live probe, limitations, and review context. It provides sufficient detail for the required template, a…
Full details: Approvability

Explanation

PASS. The pull request changes only ClaudeAdapterV2.ts and its test file. The adapter change is a focused fix to Claude goal-completion inference while background work runs. The test adds cases for that behavior. The diff does not change defaults, add diagnostic suppressions, alter packages/contracts or persisted data, affect authentication or external side effects, change dependencies, or modify CI, release, contributor, agent, or review-tool configuration.

Full details: Description check

Explanation

The description explains the problem, implementation, scope, linked issue, focused verification, live probe, limitations, and review context. It provides sufficient detail for the required template, although it does not use the template headings verbatim.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Added 1 commit

  • fix(server): a Claude /goal no longer reads as complete while a background subagent runs98d67c1

Taking over this one as maintainer for batch claude-09. I will preserve your commits, merge current main, reduce regression coverage to the behaviors this fixes, and run independent reviews before pushing. Thanks for tracing the background-subagent goal behavior.

Added 3 commits

  • Merge remote-tracking branch 'origin/main' into fix/claude-goal-background-subagentce35b20
  • test(server): simplify Claude background goal lifecycle coveragec7d069b
  • refactor(server): keep Claude goal task types with subagent statefc8188d