Skip to content

Add a simple think tool. #351

@bhouston

Description

@bhouston

This post here:
https://x.com/mattpocockuk/status/1903145626122043536

Suggests a tool like this:

import i anthropic } from "@ai-sdk/anthropic"; import i streamText } from "ai"; import { z } from "zod";
const result = await streamText({
model: anthropic ("claude-3-7-sonnet-20250219"), tools: 1
think: 1
description: *
Use the tool to think about something.
It will not obtain new information or change the database, but just append the thought to the log.
Use it when complex reasoning or some cache memory is needed.
parameters: z. object({
thought: z
•string()
• describe("A thought to think about."),
}),
execute: async (args) => 1
return {
thought: args. thought,
;
}
});

New research from Anthropic shows how a simple "think" tool can improve Claude's problem-solving skills.

Here's how to implement it in 28 lines of code.

More details:

https://www.aihero.dev/implementing-anthropics-think-tool-in-typescript

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions