Repository navigation
fix(agent): enforce tool timeouts and abort signals across background grace, approval resume, and MCP wrappers - #178
Merged
Conversation
… grace, approval resume, and MCP wrappers
Contributor
|
I'll fix CI failures and address comments from users with write access that start with 'Devin'.
|
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
Fixes three tool-timeout and abort-signal gaps in
@openrouter/agent:Background tool
timeoutMssuppressed duringgraceMs(ModelResult.handleAsyncInvocation)timeoutMstimer was only armed whenAsyncToolRegistry.trackBackgroundran aftergraceMselapsed, so background tools withtimeoutMs < graceMs(including the default250msgraceMs) ran pasttimeoutMswithout abortingctx.signal.timeoutMstimer alongside the grace-window race immediately when the background work starts, abortingcontrollerand settling with a timeout error attimeoutMs(and clearing both timers on settle so handoff totrackBackgroundwhengraceMs < timeoutMsremains single-timer).Approval-resume and auto-approve paths dropped
timeoutMs/toolTimeoutMsandctx.signal(ModelResult.processApprovalDecisions,executeAutoApproveTools,settleAsyncInvocationAsUnsent)approveToolCalls(and auto-approved tools in mixed approval rounds) calledrunToolWithHookswithoutcomposeToolSignal, execution extras (signal,callId,conversationId,client,runExtras), orraceToolDeadline.settleAsyncInvocationAsUnsent) againstraceToolDeadline, cleaning upinflightToolControllersinfinally.MCP tool wrapper dropped per-execution
ctx.signal(wrapMcpTool/invokeTool)invokeToolonly forwarded wrapper-leveloptions.signaltoclient.callTool, ignoringctx.signalcarryingtimeoutMsand run cancellation.options.signalandctx?.signalviaAbortSignal.any(preserving direct reference when only one is set) for both regular andemitProgressgenerator MCP tools.Testing
timeoutMs < graceMs(signal-aware and signal-ignoring callbacks) andtimeoutMs > graceMsinpackages/agent/tests/unit/async-tool-background.test.ts.timeoutMs, run-leveltoolTimeoutMs, approved background tools, and end-to-end MCPtoolTimeoutMsabort propagation inpackages/agent/tests/unit/tool-cancellation.test.ts.ctx.signalforwarding and composition with wrapperoptions.signalfor both regular and generator MCP tools inpackages/agent/tests/unit/mcp/call-tool-shape.test.ts.pnpm lint,pnpm typecheck,pnpm verify:packages, andpnpm test(all green).