Repository navigation
fix(agent): validate approval decisions and keep decision-less resumes paused - #131
Draft
LukasParke wants to merge 1 commit into
Draft
LukasParke wants to merge 1 commit into
LukasParke wants to merge 1 commit into
Conversation
…s paused De-duplicate approveToolCalls/rejectToolCalls in the ModelResult constructor so a repeated call ID cannot execute an approval-gated tool twice, and throw if one ID appears in both lists (typescript-sdk#518). Resuming an awaiting_approval/awaiting_hitl conversation with no decisions now stays paused instead of flipping to in_progress and sending a new model request (typescript-sdk#517). getResponse()/getText() reject with an explicit "awaiting approval" error listing the pending call IDs instead of the generic "Response not available". Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This branch has not been deployed
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.
Fixes OpenRouterTeam/typescript-sdk#518
Fixes OpenRouterTeam/typescript-sdk#517
What
Duplicate / conflicting decisions (#518). The
ModelResultconstructor now de-duplicatesapproveToolCallsandrejectToolCalls, soapproveToolCalls: ['call_1', 'call_1']executes the gated tool once and sends onefunction_call_output. An ID in both lists throws before any state is loaded or any tool runs:Tool call IDs cannot be both approved and rejected: call_2. ...Resume without decisions (#517). Before this change, loading an
awaiting_approvalorawaiting_hitlstate with no decisions fell through to the normal path. That set the status toin_progressand sent a fresh model request past calls that still needed a decision. Now the run stays paused: no request is sent and the persisted state is untouched.requiresApproval()andgetPendingToolCalls()work as before.Clearer error. When a resume leaves the conversation paused (no decisions, or decisions for only some pending calls),
getResponse()andgetText()now reject withConversation is awaiting approval (status 'awaiting_approval'); no response is available. Pending tool call IDs: .... Before, they rejected with the genericResponse not available.Behavior notes for reviewers
inputand no decisions now stays paused, and the new input is not sent. That matches the fix suggested in #517. Callers have to approve or reject first.Stream not initialized. This PR doesn't change that.Test plan
approval decision validation and paused resumes (#517, #518)block intests/unit/approval-gate-regressions.test.ts(6 tests): duplicate approve, duplicate reject, approve+reject conflict, awaiting_approval no-decision resume (no request, state unchanged, a later approval still completes), awaiting_hitl no-decision resume, and the partial-decision error message.main(e309ebf) and pass with the fix.pnpm install --frozen-lockfile,pnpm lint,pnpm typecheck,pnpm test(agent: 1242 passed, mcp: 12 passed).🤖 Generated with Claude Code