Skip to content

feat: follow active goals with Claude Code - #193103

Draft
GoatInAHat wants to merge 2 commits into
openclaw:mainfrom
GoatInAHat:openclaw/native-goal-claude-pr-20261104
Draft

GoatInAHat wants to merge 2 commits into
openclaw:mainfrom
GoatInAHat:openclaw/native-goal-claude-pr-20261104

Conversation

@GoatInAHat

Copy link
Copy Markdown
Contributor

Related: #192988. Depends on #193024.

What Problem This Solves

Active OpenClaw Goals do not drive Claude Code's native pursuit loop, and a real Goal-tool terminal verdict must stop that loop without discarding the current answer.

User Impact

An admitted Claude turn can pursue its active Goal natively while Stop, Pause, objective edits and revoked execution authority retain control. A committed complete/blocked tool verdict preserves the final reply and prevents another pursuit iteration.

This draft is not live-qualified or ready to merge. It requires Claude Code 2.1.318 or newer; exact token budgets and unrepresentable or mismatched native objectives are rejected explicitly. Durable restart recovery and Codex autonomous pursuit are separate follow-ups.

Why This Change Was Made

The existing execution owner lends a versioned Goal capability to the Claude plugin. Real managed tool calls use that same terminal transaction. Claude's native Stop callback reads the committed verdict at the transport write boundary; normal final-response and process cleanup still finish before status reconciliation.

The generic capability ships with its first working consumer. No timer, second continuation queue or provider-specific policy is added to core. The owner and its consumer stay together because splitting them would leave an unused or incomplete interface.

This branch includes the unchanged prerequisite commit from #193024. GitHub does not support native stacks across forks; the stage-only comparison isolates these changes. The prerequisite can be removed from the upstream diff after it lands.

Evidence

  • Real managed HTTP MCP transaction and owned stdio fixture: 13/13 cases pass. Complete/blocked successor-effect regressions fail on the pre-repair production files (one extra effect versus zero expected) and pass with the repair.
  • Affected native runtime, host capability, CLI policy/steering, Goal tools and session publication consumers: 278/278 tests pass across 13 files. Ordinary no-Goal Claude execution remains a sibling control.
  • Independent Codex source review covered the selective stage and terminal-Stop repair. Its production finding and two invalid fixture transitions were corrected; no actionable findings remain in that reviewed snapshot. The subsequent mechanical prompt-response extraction into the existing input helper preserves statement order and cancellation guards and has dedicated affected-check reruns. The installed native Stop contract was independently inspected, not inferred from the fixture.
  • Scoped formatting, SDK export and plugin-boundary checks, changed MDX documents, and the exact test-line ratchet pass. The separate allocation is 980 net regression lines against the prerequisite, covering native transport, real MCP terminal/cancellation and independent host ownership. The shared scalar and prerequisite's 338-line allocation are unchanged.
  • Published handoff behavior remains green: 102/102 tests across four inherited suites. In total, 393 tests pass across 18 files, with affected tests rerun after the final mechanical prompt-helper extraction. All six owning production/test type projects pass. The extraction also preserves the runtime line budget without a suppression.
  • Scoped type-aware lint passes for 14 core/registration files, nine plugin files and the managed-MCP integration test. Exact head: c0286528d78be1de21d309ae45203a31f81bbcde.

Live vendor MCP transport, real native inference/Stop evaluation, final response and external cancellation still require the isolated authenticated Gateway run. Synthetic subprocess results and native-source inspection are not presented as that live proof. A full distribution build has not been run for this stage.

@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling extensions: anthropic size: XL labels Nov 5, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 5, 2026
@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR connects active OpenClaw Goals to Claude Code’s native pursuit loop and preserves terminal Goal-tool verdicts through final-response settlement.

Example: Claude Code 2.1.318 pursues the Goal “Verify the deliverable” and calls update_goal with status complete.

  • Before: OpenClaw has no integration connecting its Goal verdict to Claude’s native pursuit loop.
  • After: The proposed integration stops another native iteration while allowing the current final reply to finish.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The source is coherent and no definite introduced defect was found, but native behavior, retained authority, and existing-state upgrade compatibility remain unqualified.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Feature · Worth it: Needs a maintainer decision · Fix scope: Partial
User problem: An active OpenClaw Goal does not drive Claude Code’s native pursuit or stop that pursuit when the managed Goal tool commits a terminal verdict.
Reason: The capability has a concrete first consumer, but expands the supported runtime contract and changes existing active-Goal execution without recorded owner approval.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep this draft open: it contains distinct native Goal integration work and is paired with an unresolved issue and prerequisite PR; the supported-runtime contract needs a maintainer decision.

Priority: P2
Reviewed head: c0286528d78be1de21d309ae45203a31f81bbcde
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should active Claude Goals automatically enter native pursuit through this new SDK capability, including hard rejection of budgeted Goals and unsupported native installations?
  • Recommendation: Approve a bounded native contract: Approve native pursuit under the existing admitted owner after qualification, with compatibility checks and actionable recovery for existing Goals; keep restart recovery and Codex autonomy separate.
  • Why: Current main deliberately limits automatic continuation to supported runtimes, and neither this PR nor its linked discussion records maintainer approval of native Claude takeover or its compatibility restrictions.

Before merge

  • Add real behavior proof - Authority-chain proof required: production HTTP MCP transactions and stdio handling run against synthetic native execution, while the body explicitly leaves real Claude inference, Stop evaluation, final replies, and external cancellation unqualified; add an isolated-Gateway trace for allowed restricted execution, forbidden sibling actions, and revocation or reassignment before further I/O, with credentials and private endpoints redacted. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Resolve security concern: Qualify authority retained across native iterations - The capability binds an operational run to Goal writes and keeps execution alive across native iterations. Supplied MCP tests cover grant deactivation and Goal invalidation, but use system admission and a synthetic peer; they do not establish forbidden sibling-agent denial or principal revocation/reassignment before native effects.
  • Resolve merge risk - Before merge, the contributor must establish that extending admitted custody across native iterations preserves restricted-caller scope and rejects revoked or reassigned authority before subsequent effects.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [medium] Qualify authority retained across native iterations — src/agents/harness/host-native-goal.ts:115

Tests

  • Missing end-to-end proof: Supply redacted isolated-Gateway evidence with real Claude showing native pursuit, terminal-tool final-reply preservation, external cancellation and forbidden-authority rejection; fixture base-failure claims do not establish that shipped scenario.
Agent review details

How this fits together

The admitted execution owner lends session Goal custody to the Claude plugin, which translates native pursuit and Stop events into existing Goal transactions and terminal replies.

flowchart TD
  A[Admitted execution] --> B[Host Goal capability]
  B --> C[Claude native pursuit]
  C --> D[Managed Goal tool]
  D --> E[Existing session writer]
  E --> F[Stop response and final settlement]
  F --> G[Goal status and user reply]
Loading

Technical review

Best possible solution:

Use the existing execution and session writers for an approved, qualified Claude-native Goal contract with explicit compatibility recovery.

Do we have a high-confidence way to reproduce the issue?

Current-main source lacks the native Goal capability and Claude Stop integration; supplied fixtures exercise the proposed behavior, but this review ran no target code.

Is this the best way to solve the issue?

The implementation reuses admitted execution, Goal transitions, publication predicates, and process cleanup; the smallest coherent stage is the prerequisite handoff repair followed by this capability with its first consumer.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8c411658c18b.

Merge-risk options

Maintainer options:

  1. Qualify retained authority before merging (recommended)
    The contributor should exercise an allowed restricted caller and a forbidden sibling-agent action, then revoke or reassign the caller and verify rejection before further native provider, tool, and reply effects.

Provenance checked

  • Inherited child-return eligibility and context consumption changes intended behavior with a stated reason (d79b0a4: Provide same-process built-in Goal continuation after committed child settlement while retaining original caller restrictions.)
  • CLI transport, approvals, steering, and cleanup keeps the original intent (58d8871: Replace the Agent SDK with plugin-owned transport while preserving host admission, final-write authorization, private context, and process lifetime.)
  • Managed Claude hook and slash-command restrictions changes intended behavior with a stated reason (96f0983: Isolate managed execution from user customizations while keeping machine-admin policy within the trusted host boundary.)
  • Retained session-entry predicates keeps the original intent (e1cb2b3: Prepare session metadata through workers and retain current published facts for synchronous checks.)
  • Existing Goal status transitions keeps the original intent (a509c48: Keep session Goals core-owned with shared persistence, controls, and model tools.)
  • Host user-turn annotation extraction keeps the original intent (f5f44fa: Bind native history operations to verified session and execution custody rather than copied authority.)

Testing

Proof path: in-process harness.

Security

Needs attention: Source retains live guards, but authority across native pursuit remains unqualified at final effects.

Evidence

Security concerns:

  • [medium] Qualify authority retained across native iterations — src/agents/harness/host-native-goal.ts:115
    The capability binds an operational run to Goal writes and keeps execution alive across native iterations. Supplied MCP tests cover grant deactivation and Goal invalidation, but use system admission and a synthetic peer; they do not establish forbidden sibling-agent denial or principal revocation/reassignment before native effects.
    Confidence: 0.94

What I checked:

  • Verified introduced change: Reviewed merge-base-to-head hunks, including the inherited prerequisite; the native consumer and versioned capability are additions absent from fetched main. (extensions/anthropic/cli-native-goal.ts:97, c0286528d78b)
  • Existing execution owns the capability: CLI execution binds the Goal to the admitted operational run and excludes isolated completion, side questions, and control operations. (src/agents/cli-runner/execute-plugin.ts:497, c0286528d78b)
  • Terminal verdict and revocation ownership: The new owner carries exact caller assertions into the existing replacement writer and retains the tool’s committed terminal postimage until execution closes. (src/agents/harness/host-native-goal.ts:264, c0286528d78b)
  • Compatibility behavior changes: An active Goal automatically selects native preparation; exact token budgets, unsupported objectives, foreign native objectives, and an unqualified Claude version reject execution. (extensions/anthropic/cli-native-goal.ts:116, c0286528d78b)
  • Supplied integration coverage: The integration test exercises real managed HTTP MCP calls, durable Goal transactions, and production stdio handling with a synthetic native peer; it uses system admission and does not establish restricted-human or live-vendor qualification. (test/plugins/claude-native-goal-mcp.gateway.test.ts:162, c0286528d78b)
  • Draft and proof declaration: The complete PR body explicitly says live vendor MCP transport, native inference and Stop evaluation, final response, and external cancellation remain unqualified; current discussion supplies no additional behavior artifact. (c0286528d78b)

PR surface

Source +850, Tests +1320, Docs +45, Other +3. Total +2218 across 41 files. Added test files: 4.

View PR surface stats
Area Files Added Removed Net
Source 27 1151 301 +850
Tests 10 1378 58 +1320
Docs 2 49 4 +45
Config 0 0 0 0
Generated 0 0 0 0
Other 2 3 0 +3
Total 41 2581 363 +2218

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Native Goal pursuit is a bounded runtime improvement without evidence of an urgent release-wide failure.
  • merge-risk: 🚨 compatibility: The PR adds a public optional capability and automatically changes execution for existing active Claude Goals, including new version and budget restrictions.
  • merge-risk: 🚨 security-boundary: Native iterations retain admitted execution authority beyond an ordinary turn boundary, requiring final-effect validation of restrictions and revocation.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add final-effect proof for the nearest unauthorized principal and prove revocation or reassignment invalidates native custody before I/O.
  • Demonstrate real Claude pursuit and final-response settlement, plus an upgrade from v2026.10.10 preserving Goals, budgets, history, settings, and explicit recovery for unsupported installations.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 4, 2026, 8:31 PM ET / November 5, 2026, 01:31 UTC.

This branch has not been deployed

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

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: anthropic merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant