Skip to content

feat: add follow-up task suggestions - #102422

Merged
steipete merged 8 commits into
mainfrom
codex/spawn-task-suggestions
Jul 9, 2026
Merged

steipete merged 8 commits into
mainfrom
codex/spawn-task-suggestions

Conversation

@steipete

@steipete steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Closes #102421

What Problem This Solves

Models can identify valuable follow-up coding work, but they previously had no operator-approved way to turn that recommendation into a fresh, isolated coding session. Plain-text suggestions are not actionable, while starting a subagent immediately skips consent and does not create a user-owned managed-worktree session.

Why This Change Was Made

This adds configurable spawn_task and dismiss_task model tools to the coding tool group. A proposal becomes an ephemeral Control UI card and never starts automatically; accepting it creates a new seeded session in its own managed worktree. The gateway owns a bounded, permission-checked lifecycle, and worktree-backed sessions consistently reuse their persisted worktree path for agent runs, replies, compaction, and sandbox reporting.

Suggestions are intentionally process-local. Acceptance is task-ID-only and idempotent, uses the server-stored prompt and project root, and rolls back partial session/worktree creation before restoring a retryable suggestion.

User Impact

Operators can inspect, accept, or dismiss model-recommended follow-up work without interrupting the current turn. Accepted work opens as a fresh coding session with the exact proposed prompt and an isolated managed worktree. Administrators can configure both tools through the existing tool policy, coding profile, and tool groups.

Evidence

  • Full changed-surface gate passed on Blacksmith Testbox: pnpm check:changed — https://github.com/openclaw/openclaw/actions/runs/28991563745
  • Focused gateway, agent-tool, worktree, sandbox, compaction, protocol, and UI suites passed; the final focused batches covered 547 assertions, with 35/35 Control UI browser cases.
  • Core production and test tsgo lanes passed.
  • pnpm ui:i18n:check and pnpm check:protocol-coverage passed.
  • Generated Swift protocol models matched the official generator byte-for-byte; native protocol guards passed.
  • git diff --check passed.
  • Fresh autoreview completed with no accepted or actionable findings.

AI assistance: Codex implemented and reviewed the change; the product contract was maintainer-provided and all reported evidence was run against the resulting patch.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime scripts Repository scripts commands Command implementations docker Docker and sandbox tooling agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Jul 9, 2026
@clawsweeper

clawsweeper Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 1:28 AM ET / 05:28 UTC.

Summary
This PR adds model-callable spawn_task/dismiss_task tools, task-suggestion gateway protocol and handlers, Control UI cards, managed-worktree session acceptance, generated client models, docs, and tests.

Reproducibility: yes. Source inspection shows isolated cron supplies both durable agentSessionKey and ephemeral runSessionKey, while task suggestions store the run key and acceptance uses it as parentSessionKey.

Review metrics: 2 noteworthy metrics.

  • Protocol/API additions: 1 sessions.create param, 4 RPC methods, 1 event added. This creates a new client/server and operator-scope contract that compatibility review must cover.
  • Model tool additions: 2 coding-profile tools added. New model-callable tools change what agents can propose during runs and need session-state and tool-policy scrutiny.

Stored data model
Persistent data-model change detected: serialized state: packages/gateway-protocol/src/schema/sessions.ts, serialized state: src/agents/tools/task-suggestion-tools.test.ts, serialized state: src/gateway/server-methods/sessions.ts, serialized state: ui/src/lib/sessions/create.ts, unknown-data-model-change: packages/gateway-protocol/src/schema/task-suggestions.ts, unknown-data-model-change: src/gateway/server-methods/sessions.ts, and 2 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #102421
Summary: This PR is the open implementation candidate for the linked feature request; it should remain open while the branch-level blocker and product/API review are resolved.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🌊 off-meta tidepool
Patch quality: 🦐 gold shrimp
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Fix suggestion ownership to use the durable agent session key and add isolated-cron regression coverage.
  • After the source blocker is fixed, a short web UI chat proof showing accept and dismiss behavior would materially improve reviewer confidence.

Mantis proof suggestion
A web UI chat proof would materially help after the source blocker is fixed because the PR adds visible chat suggestion cards and accept/dismiss interactions. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis web UI chat proof: verify that a model-suggested follow-up card can be accepted into a fresh managed-worktree chat and dismissed without starting work.

Risk before merge

  • [P1] Accepted suggestions from isolated cron runs can fail with unknown parent session because the PR stores an ephemeral run key as the suggestion owner.
  • [P1] The PR adds gateway protocol methods/events, two model-callable tools, and sessions.create cwd semantics, so compatibility and product/API review are still needed before merge.

Maintainer options:

  1. Fix durable suggestion ownership (recommended)
    Use the durable agent session key for suggestion ownership, preserve run metadata separately if needed, and add isolated-cron regression coverage before merge.
  2. Hold for API and scope review
    Pause merge until maintainers explicitly accept the new gateway protocol methods, model tools, sessions.create cwd semantics, and operator-scope behavior.
  3. Pause if core scope is wrong
    Close or pause this PR if maintainers decide model-proposed follow-up suggestions should live outside OpenClaw core for now.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Use the durable agent session key as the task suggestion source session instead of runSessionKey, keep run metadata separate if needed, and add regression coverage for isolated cron suggestions before rerunning the focused task-suggestion/openclaw-tools suites.

Next step before merge

  • [P1] A focused repair is appropriate because the blocker is a narrow key-selection and regression-coverage gap on the PR branch; product acceptance remains a maintainer decision.

Maintainer decision needed

  • Question: Should OpenClaw accept model-proposed follow-up task suggestions as a core gateway, model-tool, Control UI, and managed-worktree feature after the durable-session-key blocker is fixed?
  • Rationale: The branch adds new model-callable tools, gateway methods/events, protocol models, UI state, operator scopes, and session/worktree semantics, which is a product/API direction beyond the mechanical correctness fix.
  • Likely owner: steipete — He owns the linked product request and has the strongest recent history on the managed-worktree and session/UI surfaces this PR extends.
  • Options:
    • Fix blocker and continue review (recommended): Repair the durable source-session key bug, add the missing regression, and evaluate this PR as the canonical implementation for the linked feature request.
    • Narrow the core feature: Keep the PR open but reduce scope if maintainers want a smaller dashboard-only, tool-only, or API-only slice first.
    • Defer core scope: Pause or close the PR and linked request if maintainers decide follow-up suggestions should remain prose, subagents, or an external workflow for now.

Security
Cleared: No concrete security or supply-chain regression was found; the arbitrary-cwd worktree path is admin-gated and the diff does not change dependencies or workflow execution sources.

Review findings

  • [P2] Use the durable session key for suggestions — src/agents/openclaw-tools.ts:262-264
Review details

Best possible solution:

Accepted suggestions should be owned by the durable agent session key, with run metadata kept separately if needed; after that, maintainers should review the additive protocol, tool, UI, and worktree contract as one feature.

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

Yes. Source inspection shows isolated cron supplies both durable agentSessionKey and ephemeral runSessionKey, while task suggestions store the run key and acceptance uses it as parentSessionKey.

Is this the best way to solve the issue?

No. The implementation is plausible, but it is not the best merge candidate until task suggestions use a durable parent session key and maintainers confirm the new core API/UI direction.

Full review comments:

  • [P2] Use the durable session key for suggestions — src/agents/openclaw-tools.ts:262-264
    This still chooses runSessionKey before agentSessionKey. Isolated cron supplies a :run:<id> key that is not a persisted parent, so taskSuggestions.accept forwards it to sessions.create and gets unknown parent session; store the durable source session key and keep run metadata separately if needed.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.91

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against acac359de64e.

Label changes

Label justifications:

  • P2: This is a substantial feature PR with a concrete correctness blocker, but it is not an urgent shipped regression.
  • merge-risk: 🚨 compatibility: The branch adds gateway protocol methods/events and a sessions.create cwd parameter with new admin-scope behavior that existing clients and upgrades must tolerate.
  • merge-risk: 🚨 session-state: The branch stores and reuses session identity for accepted suggestions, and the current head can bind a suggestion to a non-persisted run session.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This is a maintainer-labeled PR from Peter Steinberger, so the external contributor real-behavior proof gate is not applied; the PR body reports CI/Testbox validation but no separate live UI artifact.
Evidence reviewed

Acceptance criteria:

  • [P1] pnpm test src/agents/openclaw-tools.update-plan.test.ts src/agents/agent-tools.create-openclaw-coding-tools.test.ts src/gateway/server-methods/task-suggestions.test.ts.
  • [P1] pnpm test src/gateway/server.sessions.create.test.ts.
  • [P1] pnpm check:protocol-coverage.

What I checked:

  • Live PR state: Live GitHub data shows this PR is open at head 2d620d11e9878a6a9dd46b45d465206919852fd3, carries the protected maintainer label, and closes the linked feature request. (2d620d11e987)
  • Prior blocker still present: The PR still derives taskSuggestionSessionKey from runSessionKey before agentSessionKey, so suggestions can be stored under a non-durable run key. (src/agents/openclaw-tools.ts:262, 2d620d11e987)
  • Ephemeral cron key source: Isolated cron builds runSessionKey with a :run:<id> suffix when the base session is cron-scoped, separate from the durable agentSessionKey. (src/cron/isolated-agent/run.ts:652, 2d620d11e987)
  • Acceptance uses stored source as parent: taskSuggestions.accept forwards suggestion.sessionKey as parentSessionKey into sessions.create, so a stored run key becomes the parent lookup key. (src/gateway/server-methods/task-suggestions.ts:147, 2d620d11e987)
  • Current parent-session contract: Current main rejects sessions.create when parentSessionKey cannot be loaded as a persisted session entry, returning unknown parent session. (src/gateway/session-create-service.ts:232, acac359de64e)
  • Feature history provenance: GitHub path history shows recent adjacent session/worktree and Control UI work by steipete, jalehman, and shakkernerd, which are the most relevant routing signals for this surface.

Likely related people:

  • steipete: He authored the linked product request and PR, and recent current-main history shows him adding managed-worktree sessions, full session controls, and related Control UI chat surfaces. (role: feature owner and recent adjacent contributor; confidence: high; commits: b4b1984fe7a9, 88f1ec38d4a5, 84f21bd9fcb1; files: src/gateway/server-methods/sessions.ts, src/gateway/session-create-service.ts, ui/src/pages/chat/chat-pane.ts)
  • jalehman: Recent current-main history moved parent-session forking and session-store bypasses through the accessor boundary, directly adjacent to the parent-session contract this PR relies on. (role: recent session-state refactor contributor; confidence: medium; commits: a68caa185bf1, 4e2a80cac34d; files: src/gateway/session-create-service.ts, src/gateway/server-methods/sessions.ts)
  • shakkernerd: Recent history touches chat behavior and prior tool-session origin work near the UI and model-tool identity surfaces used by this PR. (role: recent Control UI and tool-session contributor; confidence: medium; commits: 9d7a6b5da61b, 43bcd9ab3eee, cdcc15114508; files: ui/src/pages/chat/chat-pane.ts, src/agents/openclaw-tools.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (2 earlier review cycles)
  • reviewed 2026-07-09T05:09:28.481Z sha b5ae16d :: needs real behavior proof before merge. :: [P2] Use the durable session key for suggestions
  • reviewed 2026-07-09T05:22:37.646Z sha 2d620d1 :: needs real behavior proof before merge. :: [P2] Use the durable session key for suggestions

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d371dc415d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +262 to +264
const taskSuggestionSessionKey = normalizeOptionalString(
options?.runSessionKey ?? options?.agentSessionKey,
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Use durable session keys for task suggestions

When a caller supplies both keys, this records runSessionKey as the suggestion's source session. Isolated cron runs do this (src/cron/isolated-agent/run.ts:652 builds agent:...:cron:...:run:<id> and src/agents/agent-tools.ts:995 forwards it), but those run keys are not persisted session-store keys, so taskSuggestions.accept later passes a non-existent parentSessionKey to sessions.create and the accepted suggestion fails with unknown parent session. Store the durable agentSessionKey for suggestions and keep any run id separately if needed.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jul 9, 2026
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 2d620d11e9878a6a9dd46b45d465206919852fd3:

No known proof gaps. The model tools remain policy-configurable in the coding group; acceptance creates one operator-approved managed-worktree session from the server-stored suggestion without interrupting or auto-starting the current turn.

@steipete
steipete merged commit 5533d97 into main Jul 9, 2026
103 checks passed
@steipete
steipete deleted the codex/spawn-task-suggestions branch July 9, 2026 05:30
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 9, 2026
* feat(tools): add follow-up task suggestions

* chore: leave changelog to release flow

* fix(tools): add task suggestion display metadata

* fix(tools): update task suggestion display snapshot

* docs: format task suggestion tool table

* test(gateway): expect compaction worktree workspace

* test(gateway): preserve configured compaction workspace

* fix(ui): translate task suggestions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui commands Command implementations docker Docker and sandbox tooling docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add model-proposed follow-up task suggestions

1 participant