fix(task): preserve restricted agent tools in sync continuation#2809
Merged
code-yeongyu merged 1 commit intodevfrom Mar 24, 2026
Merged
fix(task): preserve restricted agent tools in sync continuation#2809code-yeongyu merged 1 commit intodevfrom
code-yeongyu merged 1 commit intodevfrom
Conversation
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]>
There was a problem hiding this comment.
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 placesagentonAssistantMessage, but Opencode expects it onUserMessage, 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- moveagentonto 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", |
There was a problem hiding this comment.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
exploreandlibrariansessions cannot regain nested delegation tools.f146aeff, extracted in29155ec7, and widened inf3f6ba47.Testing
bun test src/tools/delegate-task/sync-continuation.test.tsbun test src/tools/delegate-taskbun run typecheckbun run buildSummary by cubic
Preserves restricted agent tool permissions during sync continuation so resumed
exploreandlibrariansessions don’t regain delegation tools. Keeps plan-family agents’ delegation available and adds regression tests to prevent recursive subagent spawns (issue 2330).getAgentToolRestrictions(resumeAgent)after permissive defaults when buildingtools.explore,librarian, and plan-family sessions to verify expected tool sets.Written for commit 9844644. Summary will update on new commits.