Skip to content

Commit 412ceba

Browse files
fede-kamelclaude
andcommitted
fix(tools): fix type error in append_messages lambda return type
- Add cast() to fix pyright type error where lambda returns dict instead of ParseMessageCreateParamsBase - Fix bug: use params["messages"] (existing conversation) instead of messages (input variable) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e6f0370 commit 412ceba

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/anthropic/lib/tools/_beta_runner.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
Iterator,
1616
Coroutine,
1717
AsyncIterator,
18+
cast,
1819
)
1920
from contextlib import contextmanager, asynccontextmanager
2021
from typing_extensions import TypedDict, override
@@ -108,7 +109,12 @@ def append_messages(self, *messages: BetaMessageParam | ParsedBetaMessage[Respon
108109
for message in messages
109110
]
110111
self._messages_modified = True
111-
self.set_messages_params(lambda params: {**params, "messages": [*messages, *message_params]})
112+
self.set_messages_params(
113+
lambda params: cast(
114+
ParseMessageCreateParamsBase[ResponseFormatT],
115+
{**params, "messages": [*params["messages"], *message_params]},
116+
)
117+
)
112118
self._cached_tool_call_response = None
113119

114120
def _should_stop(self) -> bool:

0 commit comments

Comments
 (0)