Skip to content

Stop

Lets the model gracefully end the agent loop with an optional final message. The default loop already terminates when the model returns without any tool call; the stop tool is useful when you want an explicit “I am done” affordance, when a workflow enforces that termination is a deliberate model decision, or when a sub-agent needs to signal completion back to a coordinator via the loop’s last assistant message.

Supported in: Node.js, modern browsers (TypeScript); all platforms (Python).

This is a cooperative stop, not an abort. Any other tools the model requested in the same turn still run to completion; the loop halts after that batch without calling the model again. The final message defaults to a 4096-character cap; pass max_message_length / maxMessageLength to make_stop / makeStop when a longer summary is legitimate.

Both SDKs stop the loop through agent.cancel() with the deferred flag (agent.cancel({ message, afterCurrentTools: true }) / agent.cancel(message=..., after_current_tools=True)), so the final AgentResult is the same in each: stopReason: "cancelled" / stop_reason: "cancelled", with the stop text as the last assistant message. A sub-agent that ends this way is reported as a successful result by agent.as_tool()agent.asTool() and the subagent tool; only an immediate agent.cancel() is reported as an error.

Example:

import { Agent } from '@strands-agents/sdk'
import { stop } from '@strands-agents/sdk/vended-tools/stop'
const agent = new Agent({
tools: [stop],
systemPrompt: 'Complete the task. Call stop with a short summary when you are done.',
})
await agent.invoke('Summarize the changes in ./CHANGELOG.md')

Full API reference