cloudflare / cloudflare/agents
Think: allow rejecting an execution without auto-continuing the agent
- Dominant language
- TypeScript
- Stars
- 5.6k
- Forks
- 711
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 53
Description
## Problem
`Think.rejectExecution(executionId, reason?)` currently applies the rejected outcome to the transcript and automatically starts another model turn. This is useful when rejection means "do not perform this particular action, but keep working."
Some approval interfaces also need a second semantic: "the user rejected this action and wants the agent run to pause until they provide a new instruction." In that case, automatically continuing can cause the model to propose alternatives or keep working after the user intended to stop.
These are both valid behaviors, but `rejectExecution()` currently does not let the caller distinguish them.
## Current behavior
This appears intentional. The current implementation routes both durable-pause actions and Codemode executions through `_applyExecutionOutcome()`, which updates the transcript and triggers auto-continuation so the model can adapt to the rejection.
PR #1656 describes this model-mediated rejection behavior. There is also precedent in the AIChat approval flow for distinguishing ordinary rejection that continues from a deliberately supplied error result that does not auto-continue, as discussed in PR #967.
## Suggested API direction
Would the maintainers be open to an optional continuation policy, for example:
```ts
await agent.rejectExecution(executionId, reason, {
autoContinue: false
});
```
The default could remain `true` for backward compatibility. With `false`, Think would still durably reject the pending execution, preserve the rejection outcome, and prevent the rejected action from executing, but it would not start another model turn. A later user message could resume the conversation normally.
The exact API shape is open for discussion. A separate method or a more general resolution policy may fit the project better. Ideally, the behavior would be consistent for both durable-pause actions and Codemode executions.
## Expected semantics
- Existing callers retain the current auto-continuation behavior by default.
- `autoContinue: false` never executes the rejected action.
- The rejection remains durable and idempotent.
- No new model turn begins solely because of that rejection.
- A subsequent user message can continue the conversation normally.
This issue was researched and drafted with AI assistance. The referenced documentation and implementation were checked against the current repository before submission.
Contributor guide
Assessment
This issue has not been assessed yet.