Skip to content

fix(task): preserve restricted agent tools in sync continuation#2809

Merged
code-yeongyu merged 1 commit intodevfrom
fix/2330-recursive-subagent-spawn
Mar 24, 2026
Merged

fix(task): preserve restricted agent tools in sync continuation#2809
code-yeongyu merged 1 commit intodevfrom
fix/2330-recursive-subagent-spawn

Conversation

@code-yeongyu
Copy link
Copy Markdown
Owner

@code-yeongyu code-yeongyu commented Mar 24, 2026

Summary

Testing

  • bun test src/tools/delegate-task/sync-continuation.test.ts
  • bun test src/tools/delegate-task
  • bun run typecheck
  • bun run build

Summary by cubic

Preserves restricted agent tool permissions during sync continuation so resumed explore and librarian sessions don’t regain delegation tools. Keeps plan-family agents’ delegation available and adds regression tests to prevent recursive subagent spawns (issue 2330).

  • Bug Fixes
    • Enforces restriction precedence by applying getAgentToolRestrictions(resumeAgent) after permissive defaults when building tools.
    • Adds tests for resumed explore, librarian, and plan-family sessions to verify expected tool sets.

Written for commit 9844644. Summary will update on new commits.

Restore sync continuation to apply agent tool restrictions after permissive defaults so resumed explore and librarian sessions cannot regain nested delegation. Add regression tests for resumed restricted agents while keeping plan-family continuation behavior intact.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <[email protected]>
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files

Confidence score: 4/5

  • This PR looks safe to merge overall, with risk mainly limited to test compatibility rather than production behavior.
  • The main issue is in src/tools/delegate-task/sync-continuation.test.ts: the mock places agent on AssistantMessage, but Opencode expects it on UserMessage, which can cause misleading or failing tests around continuation flow validation.
  • Because this is a high-confidence issue (7/10 severity, 10/10 confidence) in test setup, it should be corrected soon to keep SDK-aligned coverage reliable.
  • Pay close attention to src/tools/delegate-task/sync-continuation.test.ts - move agent onto the user message mock in this and subsequent tests to match Opencode message typing.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/tools/delegate-task/sync-continuation.test.ts">

<violation number="1" location="src/tools/delegate-task/sync-continuation.test.ts:482">
P1: Custom agent: **Opencode Compatibility**

The Opencode SDK defines the `agent` property on `UserMessage`, not `AssistantMessage`. Move the `agent` property to the user message mock here and in the subsequent tests.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

role: "assistant",
time: { created: 2000 },
finish: "end_turn",
agent: "explore",
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Mar 24, 2026

Choose a reason for hiding this comment

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

P1: Custom agent: Opencode Compatibility

The Opencode SDK defines the agent property on UserMessage, not AssistantMessage. Move the agent property to the user message mock here and in the subsequent tests.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/tools/delegate-task/sync-continuation.test.ts, line 482:

<comment>The Opencode SDK defines the `agent` property on `UserMessage`, not `AssistantMessage`. Move the `agent` property to the user message mock here and in the subsequent tests.</comment>

<file context>
@@ -464,4 +464,212 @@ describe("executeSyncContinuation - toast cleanup error paths", () => {
+                role: "assistant",
+                time: { created: 2000 },
+                finish: "end_turn",
+                agent: "explore",
+              },
+              parts: [{ type: "text", text: "Response" }],
</file context>
Fix with Cubic

@code-yeongyu code-yeongyu merged commit 6ee680a into dev Mar 24, 2026
8 checks passed
@code-yeongyu code-yeongyu deleted the fix/2330-recursive-subagent-spawn branch March 24, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant