Improve in-flight cancel latency via run abort signal propagation

This commit is contained in:
William Valentin
2026-02-19 12:24:39 -08:00
parent 290303c14e
commit 2c3a00f6dd
12 changed files with 148 additions and 20 deletions
+1
View File
@@ -700,6 +700,7 @@ Cancel the current agent operation.
Used by the web dashboard/chat stop button and channel-level `/stop` / `/cancel` command fast-paths.
Cancellation is best-effort and stops at the next agent/tool-loop safe point.
Flynn now propagates a run-level abort signal into model/tool execution, so providers/tools that honor `AbortSignal` typically stop promptly instead of waiting for request/tool timeouts.
### Node Methods
+2
View File
@@ -68,6 +68,8 @@ export interface ToolExecutionContext {
}
```
`signal` is wired to run-level cancellation (`agent.cancel`, `/stop`, `/cancel`) and tool timeout. Tools should honor it for fast cooperative aborts.
### ToolResult
```typescript
+21
View File
@@ -3,6 +3,27 @@
"updated_at": "2026-02-19",
"description": "Tracks the status of all Flynn plans and implementation phases",
"plans": {
"faster-inflight-cancel-propagation": {
"status": "completed",
"date": "2026-02-19",
"updated": "2026-02-19",
"summary": "Reduced cancellation latency by wiring a run-level AbortSignal from NativeAgent into model and tool execution. `agent.cancel`/`/stop` now abort in-flight model/tool awaits immediately for signal-aware providers/tools instead of waiting for timeout/safe-point boundaries.",
"files_modified": [
"src/backends/native/agent.ts",
"src/tools/executor.ts",
"src/models/types.ts",
"src/models/openai.ts",
"src/models/github.ts",
"src/models/anthropic.ts",
"src/models/bedrock.ts",
"src/models/local/llamacpp.ts",
"src/backends/native/agent.test.ts",
"docs/api/PROTOCOL.md",
"docs/api/TOOLS.md",
"docs/plans/state.json"
],
"test_status": "pnpm test:run src/backends/native/agent.test.ts src/tools/executor.test.ts src/models/router.test.ts src/gateway/handlers/agent.test.ts + pnpm typecheck passing"
},
"makefile-skills-convenience-targets": {
"status": "completed",
"date": "2026-02-17",