Skip to content

fix(lobster): keep rejected approvals cancelled and enforce output limits - #130259

Merged
obviyus merged 1 commit into
openclaw:mainfrom
Nonosword:fix/lobster-cancellation-output-bounds
Aug 28, 2026
Merged

obviyus merged 1 commit into
openclaw:mainfrom
Nonosword:fix/lobster-cancellation-output-bounds

Conversation

@Nonosword

@Nonosword Nonosword commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Rejecting a Lobster approval returns a successful cancelled envelope. The managed-flow adapter treated every successful non-waiting envelope as complete, so the authoritative TaskFlow record became succeeded.

Embedded Lobster calls also returned structured output outside the bounded stdout and stderr streams. A model-visible JSON result could exceed maxStdoutBytes.

Why This Change Was Made

The shared run and resume path now sends cancelled envelopes to the session-bound TaskFlow cancellation authority. It never sends that outcome to generic completion. If cancellation cannot settle or rejects, the adapter returns an error without changing the flow to succeeded or failed.

All embedded run, workflow-file, and resume results now pass through one normalization point. That point measures the same pretty JSON form returned to the model and rejects it when it exceeds the configured limit.

User Impact

Rejected Lobster approvals now leave their managed TaskFlow records cancelled. Oversized embedded results now fail with lobster runtime result exceeded maxStdoutBytes instead of bypassing the output cap.

Evidence

The live check used the pinned Lobster runtime to execute a real approval-gated workflow and the production session-bound TaskFlow runtime to inspect persisted state. It ran the same inputs against exact main 8d51e415d6a14ae7b6d1023fc9661e4bc1e9c725 and head 1bbb034e2bfa8a288a8de10cce005d39e3c9da45.

Check Main Head
Reject approval after waiting Persisted succeeded Persisted cancelled
115-item result, 980 compact bytes and 3,070 model-visible bytes, with a 1,024-byte limit Returned the oversized result Rejected with the documented limit error
10-item result below the limit Returned 10 items Returned 10 items
  • node scripts/run-vitest.mjs extensions/lobster: 73 tests passed.
  • pnpm build: passed on the exact head in an isolated Linux checkout.
  • pnpm check:changed: passed on the exact head, including extension production types, test types, lint, formatting, contract tests, dead exports, database-first checks, and import-cycle checks.
  • node scripts/check-docs-mdx.mjs docs/tools/lobster.md: passed.
  • node scripts/docs-link-audit.mjs docs/tools/lobster.md: 6,908 internal links checked, 0 broken.
  • Judged line count: production +11, tests +121, docs +1. The production growth adds the TaskFlow cancellation authority and the model-visible byte contract; one canonical normalization path replaces three return-site checks.

Co-authored-by: Nonosword [email protected]

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@Nonosword

Copy link
Copy Markdown
Contributor Author

Closing to retrigger CI (check-lint/ci-gate failed due to a runner shutdown/infra flake, not code issues).

@Nonosword Nonosword closed this Aug 26, 2026
@Nonosword Nonosword reopened this Aug 26, 2026
@clawsweeper clawsweeper Bot added 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: 🧂 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. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 9:51 PM ET / August 27, 2026, 01:51 UTC.

ClawSweeper review

What this changes

The PR preserves cancelled Lobster approval outcomes in managed flows and rejects oversized result envelopes returned directly by the embedded Lobster runtime.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

The PR remains necessary: current main still finishes a cancelled Lobster envelope as a successful managed flow. The patch moves that terminal decision to the owner-scoped TaskFlow cancellation authority and adds focused coverage; no blocking defect was found.

Priority: P2
Reviewed head: b4ccb95f5fc3a0004018fbfe382aac094a5f2f4c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary fix with direct before/after runtime output and targeted regression coverage.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body includes raw before/after JSON from the production TaskFlow runtime exercising the real plugin adapters and observing both repaired outcomes; the external Lobster callable is only injected to deterministically supply its result envelope.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body includes raw before/after JSON from the production TaskFlow runtime exercising the real plugin adapters and observing both repaired outcomes; the external Lobster callable is only injected to deterministically supply its result envelope.
Evidence reviewed 7 items Current-main failure path: Current main treats only error and approval envelopes specially; a successful cancelled envelope reaches generic completion, so the managed flow can be finished instead of cancelled.
Owner-boundary correction: The PR recognizes a cancelled envelope before generic completion, invokes the bound TaskFlow cancellation method with the plugin configuration, and returns an error without failing the flow when cancellation cannot settle.
TaskFlow cancellation contract: The bound runtime scopes cancellation to the current session owner; the underlying executor first records cancellation, cancels verified child work, and only then makes the flow terminally cancelled.
Findings None None.
Security None None.

Live Verification

Command: pnpm test extensions/lobster/src/lobster-taskflow.test.ts extensions/lobster/src/lobster-runner.test.ts

Result: PASS (completed)

$ node --import tsx scripts/test-projects.mts extensions/lobster/src/lobster-taskflow.test.ts extensions/lobster/src/lobster-runner.test.ts
[test] starting test/vitest/vitest.extension-misc.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130259-44d3pt/target

 ✓  extension-misc  extensions/lobster/src/lobster-taskflow.test.ts (10 tests) 143ms
 ✓  extension-misc  extensions/lobster/src/lobster-runner.test.ts (25 tests) 347ms

 Test Files  2 passed (2)
      Tests  35 passed (35)
   Start at  01:52:04
   Duration  2.16s (transform 2.70s, setup 2.30s, import 303ms, tests 489ms, environment 0ms)

[test] passed 1 Vitest shard in 7.94s
$ node --import tsx scripts/test-projects.mts extensions/lobster/src/lobster-taskflow.test.ts extensions/lobster/src/lobster-runner.test.ts
[test] starting test/vitest/vitest.extension-misc.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130259-44d3pt/target

 ✓  extension-misc  extensions/lobster/src/lobster-taskflow.test.ts (10 tests) 75ms
 ✓  extension-misc  extensions/lobster/src/lobster-runner.test.ts (25 tests) 343ms

 Test Files  2 passed (2)
      Tests  35 passed (35)
   Start at  01:52:13
   Duration  1.32s (transform 1.06s, setup 1.19s, import 141ms, tests 418ms, environment 0ms)

[test] passed 1 Vitest shard in 7.07s

Assertions:

  • PASS expect_output: Test Files 2 passed

How this fits together

The optional Lobster plugin converts embedded workflow-runtime envelopes into OpenClaw tool results. Managed requests additionally update a session-owned TaskFlow, while embedded responses bypass stdout/stderr streams and must be bounded before returning to the agent.

flowchart TD
  A[Agent tool request] --> B[Lobster plugin]
  B --> C[Embedded workflow runtime]
  C --> D[Result envelope]
  D --> E{Managed flow request?}
  E -->|Yes| F[Session-owned TaskFlow]
  E -->|No| G[Bounded tool result]
  F --> G
Loading

Before merge

  • Resolve merge risk (P1) - This bug fix adds 64 net production lines and changes persisted managed-flow terminal state; the added surface is warranted by using TaskFlow’s existing asynchronous cancellation authority and applying the cap at all three embedded return paths, but it carries normal session-state merge risk.
  • Complete next step (P2) - No repair lane is needed: the contributor branch already contains the focused correction, pending normal exact-head merge validation.
Agent review details

Security

None.

PR surface

Source +64, Tests +101. Total +165 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 69 5 +64
Tests 2 102 1 +101
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 171 6 +165

Review metrics

Metric Value Why it matters
Production versus test LOC production +69/-5 (net +64); tests +102/-1 (net +101) The production growth implements one async cancellation path and one shared envelope bound across three return paths; the test growth covers the new terminal-state and size-limit cases.

Stored data model

Persistent data-model change detected: serialized state: extensions/lobster/src/lobster-runner.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Retain authoritative cancellation (recommended)
    Accept the intended managed-flow state transition after exact-head validation, since TaskFlow already owns child-work cancellation and session scoping.

Technical review

Best possible solution:

Land the focused plugin-owner repair after the normal exact-head merge gates pass, retaining TaskFlow as the sole authority for managed cancellation and the embedded-return boundary as the output-cap owner.

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

Yes. Current main source proves that cancelled envelopes reach generic completion, and the PR body supplies a reproducible before/after run through the real TaskFlow runtime with the persisted status observed.

Is this the best way to solve the issue?

Yes. The adapter now delegates cancellation to the existing session-scoped TaskFlow authority; changing stdout sinks alone cannot bound an embedded result returned directly from the runtime.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes raw before/after JSON from the production TaskFlow runtime exercising the real plugin adapters and observing both repaired outcomes; the external Lobster callable is only injected to deterministically supply its result envelope.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes raw before/after JSON from the production TaskFlow runtime exercising the real plugin adapters and observing both repaired outcomes; the external Lobster callable is only injected to deterministically supply its result envelope.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This repairs a bounded but real optional-plugin workflow state and output-limit defect on current main.
  • merge-risk: 🚨 session-state: Merging changes the persisted terminal state of managed Lobster flows and may cancel linked child work through TaskFlow.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes raw before/after JSON from the production TaskFlow runtime exercising the real plugin adapters and observing both repaired outcomes; the external Lobster callable is only injected to deterministically supply its result envelope.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes raw before/after JSON from the production TaskFlow runtime exercising the real plugin adapters and observing both repaired outcomes; the external Lobster callable is only injected to deterministically supply its result envelope.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Blame assigns the original generic completion branch to the TaskFlow extraction commit, and history shows sustained authorship of both Lobster owner modules. (role: introduced current managed-flow adapter and recent area contributor; confidence: high; commits: 6f3cda9e53ae, 08b9c4c3e140; files: extensions/lobster/src/lobster-taskflow.ts, extensions/lobster/src/lobster-runner.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (3 earlier review cycles)
  • reviewed 2026-08-26T18:01:30.086Z sha 48995d9d49fee8b77dc7b993022b62a92722767c :: needs real behavior proof before merge. :: [P2] Preserve cancellation when the TaskFlow cancel call rejects
  • reviewed 2026-08-26T18:24:18.091Z sha 4a56d7ccbde79ab39eb951aa4aaab684ee442870 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-26T19:03:41.108Z sha b4ccb95f5fc3a0004018fbfe382aac094a5f2f4c :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 26, 2026
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 26, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 27, 2026
@obviyus
obviyus force-pushed the fix/lobster-cancellation-output-bounds branch from b4ccb95 to 1bbb034 Compare August 28, 2026 08:06
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M and removed size: S labels Aug 28, 2026
@obviyus

obviyus commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Thanks @Nonosword!

Proof: A real approval-gated workflow from the pinned Lobster runtime moved its production TaskFlow record from waiting to succeeded on main and from waiting to cancelled on this head. A 3,070-byte model-visible result passed a 1,024-byte limit on main and was rejected on this head, while a 340-byte result still returned normally. node scripts/run-vitest.mjs extensions/lobster passed 73 tests. Exact-head pnpm build, pnpm check:changed, local ClawSweeper, and openclaw/ci-gate run 33154025489 passed with no proof gap.

  • Bug: Rejecting a Lobster approval could record its managed flow as succeeded, and embedded JSON results could bypass the output limit.
  • Fix: The shared run/resume owner now cancels the TaskFlow and checks every model-visible embedded result at one bounded normalization point.

Example

Before After
Rejected approval: TaskFlow succeeded; 3,070-byte result returned under a 1,024-byte limit. Rejected approval: TaskFlow cancelled; the oversized result returns lobster runtime result exceeded maxStdoutBytes.

@obviyus
obviyus merged commit ae49990 into openclaw:main Aug 28, 2026
191 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 29, 2026
…w#130259)

Keep managed Lobster state aligned with rejected approvals and enforce the configured byte limit on the JSON returned to the model.

Co-authored-by: Nonosword <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: lobster Extension: lobster merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants