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

bash-tool changedagents-and-tools/tool-use/bash-tool

Nearest release: v2.1.309, published 3 hours before 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+21added
Lines−19removed
From line 146 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits11to this page, all time

The whole hunk

from line 146, old and new numbered
/
lines
from line 146
146146 ```
147147 
148148 ```php PHP
149 use Anthropic\Messages\Model;
149150 use Anthropic\Messages\ToolBash20250124;
150151 
151152 $client = new Client();
152153 
153154 $response = $client->messages->create(
154 model: 'claude-opus-5-5',
155 model: Model::CLAUDE_OPUS_5_5,
155156 maxTokens: 1024,
156157 tools: [new ToolBash20250124()],
157158 messages: [
from line 307
306307 
307308 def execute_command(self, command):
308309 """Run a command in the session and return its output."""
309 sentinel = f"__CLAUDE_BASH_DONE_{uuid.uuid4().hex}__" # unique per call
310 sentinel = f"__CLAUDE_BASH_DONE_{uuid.uuid4().hex}__" # unique for each call
310311 self.process.stdin.write(f"{command}\necho {sentinel}\n")
311312 self.process.stdin.flush()
312313 
from line 353
352353 
353354 // Run a command in the session and return its output.
354355 executeCommand(command: string): Promise<string> {
355 const sentinel = `__CLAUDE_BASH_DONE_${randomUUID()}__`; // unique per call
356 const sentinel = `__CLAUDE_BASH_DONE_${randomUUID()}__`; // unique for each call
356357 const output: string[] = [];
357358 const result = new Promise<string>((resolve) => {
358359 const onLine = (line: string): void => {
from line 417
416417 // Run a command in the session and return its output.
417418 public string ExecuteCommand(string command)
418419 {
419 var sentinel = $"__CLAUDE_BASH_DONE_{Guid.NewGuid():N}__"; // unique per call
420 var sentinel = $"__CLAUDE_BASH_DONE_{Guid.NewGuid():N}__"; // unique for each call
420421 Process.StandardInput.Write($"{command}\necho {sentinel}\n");
421422 Process.StandardInput.Flush();
422423 
from line 484
483484 func (s *BashSession) ExecuteCommand(command string) string {
484485 buf := make([]byte, 16)
485486 rand.Read(buf)
486 sentinel := fmt.Sprintf("__CLAUDE_BASH_DONE_%s__", hex.EncodeToString(buf)) // unique per call
487 sentinel := fmt.Sprintf("__CLAUDE_BASH_DONE_%s__", hex.EncodeToString(buf)) // unique for each call
487488 fmt.Fprintf(s.stdin, "%s\necho %s\n", command, sentinel)
488489 
489490 var output strings.Builder
from line 548
547548 
548549 // Run a command in the session and return its output.
549550 String executeCommand(String command) throws IOException {
550 String sentinel = "__CLAUDE_BASH_DONE_" + UUID.randomUUID() + "__"; // unique per call
551 String sentinel = "__CLAUDE_BASH_DONE_" + UUID.randomUUID() + "__"; // unique for each call
551552 stdin.write(command + "\necho " + sentinel + "\n");
552553 stdin.flush();
553554 
from line 605
604605 // Run a command in the session and return its output.
605606 public function executeCommand(string $command): string
606607 {
607 $sentinel = '__CLAUDE_BASH_DONE_' . bin2hex(random_bytes(16)) . '__'; // unique per call
608 $sentinel = '__CLAUDE_BASH_DONE_' . bin2hex(random_bytes(16)) . '__'; // unique for each call
608609 fwrite($this->stdin, "{$command}\necho {$sentinel}\n");
609610 fflush($this->stdin);
610611 
from line 628
627628 }
628629 
629630 $session = new BashSession();
630 echo $session->executeCommand("cd /tmp && pwd");
631 echo $session->executeCommand("pwd"); // still /tmp: the session kept its state
631 echo $session->executeCommand('cd /tmp && pwd');
632 echo $session->executeCommand('pwd'); // still /tmp: the session kept its state
632633 ```
633634 
634635 ```ruby Ruby
from line 646
645646 
646647 # Run a command in the session and return its output.
647648 def execute_command(command)
648 sentinel = "__CLAUDE_BASH_DONE_#{SecureRandom.hex(16)}__" # unique per call
649 sentinel = "__CLAUDE_BASH_DONE_#{SecureRandom.hex(16)}__" # unique for each call
649650 @stdin.write("#{command}\necho #{sentinel}\n")
650651 @stdin.flush
651652 
from line 698
697698 command = content.input.get("command")
698699 result = bash_session.execute_command(command)
699700 
700 # One tool_result per tool_use block, all returned in the next user message
701 # One tool_result for each tool_use block, all returned in the next user message
701702 tool_results.append(
702703 {"type": "tool_result", "tool_use_id": content.id, "content": result}
703704 )
from line 716
715716 result = await bashSession.executeCommand(block.input.command ?? "");
716717 }
717718 
718 // One tool_result per tool_use block, all returned in the next user message
719 // One tool_result for each tool_use block, all returned in the next user message
719720 toolResults.push({ type: "tool_result", tool_use_id: block.id, content: result });
720721 }
721722 }
from line 740
739740 result = bashSession.ExecuteCommand(command);
740741 }
741742 
742 // One tool_result per tool_use block, all returned in the next user message
743 // One tool_result for each tool_use block, all returned in the next user message
743744 toolResults.Add(new ToolResultBlockParam { ToolUseID = toolUse.ID, Content = result });
744745 }
745746 }
from line 766
765766 result = bashSession.ExecuteCommand(input.Command)
766767 }
767768 
768 // One tool_result per tool_use block, all returned in the next user message
769 // One tool_result for each tool_use block, all returned in the next user message
769770 toolResults = append(toolResults, anthropic.NewToolResultBlock(block.ID, result, false))
770771 }
771772 }
from line 785
784785 result = bashSession.executeCommand(command);
785786 }
786787 
787 // One tool_result per tool_use block, all returned in the next user message
788 // One tool_result for each tool_use block, all returned in the next user message
788789 toolResults.add(Map.of("type", "tool_result", "tool_use_id", block.id(), "content", result));
789790 }
790791 }
from line 802
801802 $result = $bashSession->executeCommand($block->input['command']);
802803 }
803804 
804 // One tool_result per tool_use block, all returned in the next user message
805 // One tool_result for each tool_use block, all returned in the next user message
805806 $toolResults[] = ['type' => 'tool_result', 'tool_use_id' => $block->id, 'content' => $result];
806807 }
807808 }
from line 821
820821 bash_session.execute_command(block.input[:command])
821822 end
822823 
823 # One tool_result per tool_use block, all returned in the next user message
824 # One tool_result for each tool_use block, all returned in the next user message
824825 tool_results << {type: "tool_result", tool_use_id: block.id, content: result}
825826 end
826827 ```
from line 1107
11061107 ```
11071108 
11081109 ```php PHP
1110 use Anthropic\Messages\Model;
11091111 use Anthropic\Messages\ToolBash20250124;
11101112 
11111113 $client = new Client();
11121114 
11131115 $response = $client->messages->create(
1114 model: 'claude-opus-5-5',
1116 model: Model::CLAUDE_OPUS_5_5,
11151117 maxTokens: 1024,
11161118 tools: [new ToolBash20250124()],
11171119 messages: [
from line 1606
16041606 // readable output before each fgets() so the loop can check the deadline.
16051607 function executeWithTimeout(BashSession $session, string $command, int $timeout = 30): string
16061608 {
1607 $sentinel = '__CLAUDE_BASH_DONE_' . bin2hex(random_bytes(16)) . '__'; // unique per call
1609 $sentinel = '__CLAUDE_BASH_DONE_' . bin2hex(random_bytes(16)) . '__'; // unique for each call
16081610 fwrite($session->stdin, "{$command}\necho {$sentinel}\n");
16091611 fflush($session->stdin);
16101612 
Feedback