Follow Discord
Sweep 22 Oct 2026 · 04:32Z Build v2.1.308 527 read Stable v2.1.308 Latest v2.1.308 Next v2.1.308 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · api

build-a-tool-using-agent changedagents-and-tools/tool-use/build-a-tool-using-agent

Nearest release: v2.1.307, published 4 hours after this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.

Recorded here
Lines+35added
Lines−58removed
From line 304 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits12to this page, all time

The whole hunk

from line 304, old and new numbered
/
lines
from line 304
304304 MaxTokens = 1024,
305305 Tools = tools,
306306 ToolChoice = toolChoice,
307 Messages = [new() { Role = Role.User, Content = userPrompt }],
307 Messages = [new UserMessageParam { Content = userPrompt }],
308308 });
309309 
310310 // When Claude calls a tool, the response has stop_reason "tool_use"
from line 349
349349 ToolChoice = toolChoice,
350350 Messages =
351351 [
352 new() { Role = Role.User, Content = userPrompt },
353 new() { Role = Role.Assistant, Content = response.Content.Select(block => new ContentBlockParam(block.Json)).ToList() },
354 new() { Role = Role.User, Content = new MessageParamContent(toolResults) },
352 new UserMessageParam { Content = userPrompt },
353 new AssistantMessageParam { Content = response.Content.Select(block => new ContentBlockParam(block.Json)).ToList() },
354 new UserMessageParam { Content = toolResults },
355355 ],
356356 });
357357 
from line 588
588588 .toolChoice(toolChoice)
589589 .addUserMessage(userPrompt)
590590 .addMessage(response)
591 .addUserMessageOfBlockParams(List.of(ContentBlockParam.ofToolResult(
591 .addUserMessageOfContentBlockParams(List.of(ContentBlockParam.ofToolResult(
592592 ToolResultBlockParam.builder()
593593 .toolUseId(toolUse.id())
594594 .content(result)
from line 1100
11001100 // Keep the full conversation history in a list so each turn sees prior context.
11011101 List<MessageParam> messages =
11021102 [
1103 new()
1103 new UserMessageParam
11041104 {
1105 Role = Role.User,
11061105 Content = "Schedule a weekly team standup every Monday at 9am for the next 4 weeks, starting Monday, March 30, 2026. Invite the whole team: [email protected], [email protected], [email protected].",
11071106 },
11081107 ];
from line 1130
11311130 }
11321131 var result = RunTool(toolUse!);
11331132 
1134 messages.Add(new()
1133 messages.Add(new AssistantMessageParam
11351134 {
1136 Role = Role.Assistant,
11371135 Content = response.Content.Select(block => new ContentBlockParam(block.Json)).ToList(),
11381136 });
1139 messages.Add(new()
1137 messages.Add(new UserMessageParam
11401138 {
1141 Role = Role.User,
1142 Content = new MessageParamContent(
1139 Content = new MessageContentParam(
11431140 [
11441141 new ContentBlockParam(new ToolResultBlockParam() { ToolUseID = toolUse!.ID, Content = result }),
11451142 ]),
from line 1345
13481345 
13491346 // Keep the full conversation history in a list so each turn sees prior context.
13501347 List<MessageParam> messages = new ArrayList<>();
1351 messages.add(MessageParam.builder()
1352 .role(MessageParam.Role.USER)
1353 .content("Schedule a weekly team standup every Monday at 9am for the next 4 weeks, starting Monday, March 30, 2026. Invite the whole team: [email protected], [email protected], [email protected].")
1354 .build());
1348 messages.add(MessageParam.ofUser(
1349 "Schedule a weekly team standup every Monday at 9am for the next 4 weeks, starting Monday, March 30, 2026. Invite the whole team: [email protected], [email protected], [email protected]."));
13551350 
13561351 Message response = client.messages().create(MessageCreateParams.builder()
13571352 .model(Model.CLAUDE_OPUS_5_5)
from line 1367
13721367 String result = runTool(toolUse);
13731368 
13741369 messages.add(response.toParam());
1375 messages.add(MessageParam.builder()
1376 .role(MessageParam.Role.USER)
1377 .contentOfBlockParams(List.of(ContentBlockParam.ofToolResult(
1378 ToolResultBlockParam.builder()
1379 .toolUseId(toolUse.id())
1380 .content(result)
1381 .build())))
1382 .build());
1370 messages.add(MessageParam.ofUserOfContentBlockParams(List.of(ContentBlockParam.ofToolResult(
1371 ToolResultBlockParam.builder()
1372 .toolUseId(toolUse.id())
1373 .content(result)
1374 .build()))));
13831375 
13841376 response = client.messages().create(MessageCreateParams.builder()
13851377 .model(Model.CLAUDE_OPUS_5_5)
from line 1899
19071899 
19081900 List<MessageParam> messages =
19091901 [
1910 new()
1902 new UserMessageParam
19111903 {
1912 Role = Role.User,
19131904 Content = "Check what I have on Monday, March 30, 2026, then schedule a one-hour planning session that day that avoids any conflicts.",
19141905 },
19151906 ];
from line 1930
19391930 }
19401931 }
19411932 
1942 messages.Add(new()
1933 messages.Add(new AssistantMessageParam
19431934 {
1944 Role = Role.Assistant,
19451935 Content = response.Content.Select(block => new ContentBlockParam(block.Json)).ToList(),
19461936 });
1947 messages.Add(new() { Role = Role.User, Content = new MessageParamContent(toolResults) });
1937 messages.Add(new UserMessageParam { Content = toolResults });
19481938 
19491939 response = await client.Messages.Create(new MessageCreateParams
19501940 {
from line 2149
21592149 .build();
21602150 
21612151 List<MessageParam> messages = new ArrayList<>();
2162 messages.add(MessageParam.builder()
2163 .role(MessageParam.Role.USER)
2164 .content("Check what I have on Monday, March 30, 2026, then schedule a one-hour planning session that day that avoids any conflicts.")
2165 .build());
2152 messages.add(MessageParam.ofUser(
2153 "Check what I have on Monday, March 30, 2026, then schedule a one-hour planning session that day that avoids any conflicts."));
21662154 
21672155 Message response = client.messages().create(MessageCreateParams.builder()
21682156 .model(Model.CLAUDE_OPUS_5_5)
from line 2177
21892177 }
21902178 
21912179 messages.add(response.toParam());
2192 messages.add(MessageParam.builder()
2193 .role(MessageParam.Role.USER)
2194 .contentOfBlockParams(toolResults)
2195 .build());
2180 messages.add(MessageParam.ofUserOfContentBlockParams(toolResults));
21962181 
21972182 response = client.messages().create(MessageCreateParams.builder()
21982183 .model(Model.CLAUDE_OPUS_5_5)
from line 2740
27552740 
27562741 List<MessageParam> messages =
27572742 [
2758 new() { Role = Role.User, Content = $"Schedule a one-hour all-hands on Monday, March 30, 2026 at 10am with everyone: {emails}" },
2743 new UserMessageParam { Content = $"Schedule a one-hour all-hands on Monday, March 30, 2026 at 10am with everyone: {emails}" },
27592744 ];
27602745 
27612746 var response = await client.Messages.Create(new MessageCreateParams
from line 2777
27922777 }
27932778 }
27942779 
2795 messages.Add(new()
2780 messages.Add(new AssistantMessageParam
27962781 {
2797 Role = Role.Assistant,
27982782 Content = response.Content.Select(block => new ContentBlockParam(block.Json)).ToList(),
27992783 });
2800 messages.Add(new() { Role = Role.User, Content = new MessageParamContent(toolResults) });
2784 messages.Add(new UserMessageParam { Content = toolResults });
28012785 
28022786 response = await client.Messages.Create(new MessageCreateParams
28032787 {
from line 3021
30373021 .collect(Collectors.joining(", "));
30383022 
30393023 List<MessageParam> messages = new ArrayList<>();
3040 messages.add(MessageParam.builder()
3041 .role(MessageParam.Role.USER)
3042 .content("Schedule a one-hour all-hands on Monday, March 30, 2026 at 10am with everyone: " + emails)
3043 .build());
3024 messages.add(MessageParam.ofUser(
3025 "Schedule a one-hour all-hands on Monday, March 30, 2026 at 10am with everyone: " + emails));
30443026 
30453027 Message response = client.messages().create(MessageCreateParams.builder()
30463028 .model(Model.CLAUDE_OPUS_5_5)
from line 3051
30693051 }
30703052 
30713053 messages.add(response.toParam());
3072 messages.add(MessageParam.builder()
3073 .role(MessageParam.Role.USER)
3074 .contentOfBlockParams(toolResults)
3075 .build());
3054 messages.add(MessageParam.ofUserOfContentBlockParams(toolResults));
30763055 
30773056 response = client.messages().create(MessageCreateParams.builder()
30783057 .model(Model.CLAUDE_OPUS_5_5)
from line 3469
34903469 using Anthropic.Models.Beta.Messages;
34913470 using MessageCreateParams = Anthropic.Models.Beta.Messages.MessageCreateParams;
34923471 using InputSchema = Anthropic.Models.Beta.Messages.InputSchema;
3493 using Role = Anthropic.Models.Beta.Messages.Role;
34943472 using Model = Anthropic.Models.Messages.Model;
34953473 
34963474 AnthropicClient client = new();
from line 3552
35743552 MaxTokens = 1024,
35753553 Messages =
35763554 [
3577 new()
3555 new BetaUserMessageParam
35783556 {
3579 Role = Role.User,
35803557 Content = "Check what I have on Monday, March 30, 2026, then schedule a one-hour planning session that day that avoids any conflicts.",
35813558 },
35823559 ],
Feedback