Skip to content

Commit 38391da

Browse files
parisac-antclaude
andauthored
Add Claude 4.5 Sonnet support and update default model (#296)
* Fix claude-sonnet-4-5-20250929 tool compatibility - Add EditTool20250728 with text_editor_20250728 API type and str_replace_based_edit_tool name - Update computer_use_20250124 to use EditTool20250728 instead of EditTool20250124 - Add CLAUDE_4_5 model configuration using computer_use_20250124 tool version - Update model mapping to use CLAUDE_4_5 for claude-sonnet-4-5-20250929 - Set claude-sonnet-4-5-20250929 as the default model This resolves the "does not support tool types: text_editor_20250124" error by using the official tool types supported by the model: bash_20250124, computer_20250124, text_editor_20250728. Uses official computer_use_20250124 tool version instead of inventing a new one. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * Update README to reflect Claude 4.5 Sonnet as default model Updates the default model reference from claude-sonnet-4-20250514 to claude-sonnet-4-5-20250929 in the README note section. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * remove unused import --------- Co-authored-by: Claude <[email protected]>
1 parent 47354ff commit 38391da

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

computer-use-demo/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Anthropic Computer Use Demo
22

33
> [!NOTE]
4-
> Now featuring support for the new Claude 4 models! The latest Claude 4 Sonnet (claude-sonnet-4-20250514) is now the default model, with Claude 4 Opus (claude-opus-4-20250514) also available. These models bring next-generation capabilities with the updated str_replace_based_edit_tool that replaces the previous str_replace_editor tool. The undo_edit command has been removed in this latest version for a more streamlined experience.
4+
> Now featuring support for the new Claude 4 models! The latest Claude 4.5 Sonnet (claude-sonnet-4-5-20250929) is now the default model, with Claude 4 Sonnet (claude-sonnet-4-20250514) and Claude 4 Opus (claude-opus-4-20250514) also available. These models bring next-generation capabilities with the updated str_replace_based_edit_tool that replaces the previous str_replace_editor tool. The undo_edit command has been removed in this latest version for a more streamlined experience.
55
66
> [!CAUTION]
77
> Computer use is a beta feature. Please be aware that computer use poses unique risks that are distinct from standard API features or chat interfaces. These risks are heightened when using computer use to interact with the internet. To minimize risks, consider taking precautions such as:

computer-use-demo/computer_use_demo/streamlit.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from computer_use_demo.tools import ToolResult, ToolVersion
3333

3434
PROVIDER_TO_DEFAULT_MODEL_NAME: dict[APIProvider, str] = {
35-
APIProvider.ANTHROPIC: "claude-sonnet-4-20250514",
35+
APIProvider.ANTHROPIC: "claude-sonnet-4-5-20250929",
3636
APIProvider.BEDROCK: "anthropic.claude-3-5-sonnet-20241022-v2:0",
3737
APIProvider.VERTEX: "claude-3-5-sonnet-v2@20241022",
3838
}
@@ -66,10 +66,18 @@ class ModelConfig:
6666
has_thinking=True,
6767
)
6868

69+
CLAUDE_4_5 = ModelConfig(
70+
tool_version="computer_use_20250124",
71+
max_output_tokens=128_000,
72+
default_output_tokens=1024 * 16,
73+
has_thinking=True,
74+
)
75+
6976
MODEL_TO_MODEL_CONF: dict[str, ModelConfig] = {
7077
"claude-3-7-sonnet-20250219": SONNET_3_7,
7178
"claude-opus-4@20250508": CLAUDE_4,
7279
"claude-sonnet-4-20250514": CLAUDE_4,
80+
"claude-sonnet-4-5-20250929": CLAUDE_4_5,
7381
"claude-opus-4-20250514": CLAUDE_4,
7482
}
7583

@@ -513,10 +521,10 @@ def _render_message(
513521
thinking_content = message.get("thinking", "")
514522
st.markdown(f"[Thinking]\n\n{thinking_content}")
515523
elif message["type"] == "tool_use":
516-
st.code(f'Tool Use: {message["name"]}\nInput: {message["input"]}')
524+
st.code(f"Tool Use: {message['name']}\nInput: {message['input']}")
517525
else:
518526
# only expected return types are text and tool_use
519-
raise Exception(f'Unexpected response type {message["type"]}')
527+
raise Exception(f"Unexpected response type {message['type']}")
520528
else:
521529
st.markdown(message)
522530

computer-use-demo/computer_use_demo/tools/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from .bash import BashTool20241022, BashTool20250124
33
from .collection import ToolCollection
44
from .computer import ComputerTool20241022, ComputerTool20250124
5-
from .edit import EditTool20241022, EditTool20250124, EditTool20250429
5+
from .edit import EditTool20241022, EditTool20250124, EditTool20250429, EditTool20250728
66
from .groups import TOOL_GROUPS_BY_VERSION, ToolVersion
77

88
__ALL__ = [
@@ -14,6 +14,7 @@
1414
EditTool20241022,
1515
EditTool20250124,
1616
EditTool20250429,
17+
EditTool20250728,
1718
ToolCollection,
1819
ToolResult,
1920
ToolVersion,

computer-use-demo/computer_use_demo/tools/edit.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,5 +557,10 @@ def _make_output(
557557
)
558558

559559

560+
class EditTool20250728(EditTool20250124):
561+
api_type: Literal["text_editor_20250728"] = "text_editor_20250728" # pyright: ignore[reportIncompatibleVariableOverride]
562+
name: Literal["str_replace_based_edit_tool"] = "str_replace_based_edit_tool" # pyright: ignore[reportIncompatibleVariableOverride]
563+
564+
560565
class EditTool20241022(EditTool20250124):
561566
api_type: Literal["text_editor_20250429"] = "text_editor_20250429" # pyright: ignore[reportIncompatibleVariableOverride]

computer-use-demo/computer_use_demo/tools/groups.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from .base import BaseAnthropicTool
55
from .bash import BashTool20241022, BashTool20250124
66
from .computer import ComputerTool20241022, ComputerTool20250124
7-
from .edit import EditTool20241022, EditTool20250124, EditTool20250429
7+
from .edit import EditTool20241022, EditTool20250429, EditTool20250728
88

99
ToolVersion = Literal[
1010
"computer_use_20250124", "computer_use_20241022", "computer_use_20250429"
@@ -29,7 +29,7 @@ class ToolGroup:
2929
),
3030
ToolGroup(
3131
version="computer_use_20250124",
32-
tools=[ComputerTool20250124, EditTool20250124, BashTool20250124],
32+
tools=[ComputerTool20250124, EditTool20250728, BashTool20250124],
3333
beta_flag="computer-use-2025-01-24",
3434
),
3535
ToolGroup(

0 commit comments

Comments
 (0)