coinbase / coinbase/agentkit

Add built-in execution timeout and cancellation support for long-running agent actions

Open
#894 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.3k
Forks
815
Avg merge
13h 31m
Merged PRs (30d)
2

Description

### Language Implementation

- [ ] Python
- [x] TypeScript

### Feature Type

- [ ] Action Provider Template
- [ ] Wallet Provider Template
- [x] Framework Extension
- [ ] Core Requirements
- [ ] Other

### 🚀 The feature, motivation and pitch

AgentKit agents may execute long-running or multi-step actions (onchain calls, polling, retries, external API requests). Currently, there is no first-class way to apply execution timeouts or cancel in-progress actions, which can lead to stalled agents and wasted resources.

## Problem Description
In real-world deployments:
- An action may hang due to slow RPC responses or external service delays.
- Agents may need to stop execution when a user cancels a task or a higher-level timeout is reached.
- Developers must manually implement cancellation logic using custom flags or wrappers.

### Alternatives

### Proposed Solution
- Add optional execution timeout configuration at two levels:
- global default during `AgentKit` initialization
- per-action override when invoking an action
- Support cancellation using a standard mechanism such as `AbortSignal`.
- Propagate cancellation and timeout signals to:
- retries
- polling loops
- underlying RPC or external API calls
- Emit a distinct, typed error for timeout and cancellation events.

### Acceptance Criteria
- Long-running actions terminate automatically when the timeout is reached.
- Manual cancellation cleanly stops all in-progress work.
- Consumers receive clear, typed timeout or cancellation errors.
- Existing agents continue to work unchanged when no timeout is configured.
- Unit tests cover timeout expiration and cancellation paths.

### Additional context

## Example code
```ts
import { AgentKit } from "@coinbase/agentkit";

const agent = new AgentKit({
// desired: global timeout / cancellation config
});

await agent.evm.sendTransaction({
network: "base",
to: "0x...",
value: "0",
data: "0x",
// desired: per-action timeout
});

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.