feat: latest hitl + parallel tool call changes (#5565)
This commit is contained in:
@@ -39,6 +39,7 @@ from letta.schemas.letta_stop_reason import LettaStopReason, StopReasonType
|
||||
from letta.schemas.message import Message
|
||||
from letta.schemas.openai.chat_completion_response import FunctionCall, ToolCall
|
||||
from letta.server.rest_api.json_parser import JSONParser, PydanticJSONParser
|
||||
from letta.server.rest_api.utils import increment_message_uuid
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
@@ -282,14 +283,12 @@ class SimpleAnthropicStreamingInterface:
|
||||
call_id = content.id
|
||||
# Initialize arguments from the start event's input (often {}) to avoid undefined in UIs
|
||||
if name in self.requires_approval_tools:
|
||||
if prev_message_type and prev_message_type != "approval_request_message":
|
||||
message_index += 1
|
||||
tool_call_msg = ApprovalRequestMessage(
|
||||
id=self.letta_message_id,
|
||||
id=increment_message_uuid(self.letta_message_id),
|
||||
# Do not emit placeholder arguments here to avoid UI duplicates
|
||||
tool_call=ToolCallDelta(name=name, tool_call_id=call_id),
|
||||
date=datetime.now(timezone.utc).isoformat(),
|
||||
otid=Message.generate_otid_from_id(self.letta_message_id, message_index),
|
||||
otid=Message.generate_otid_from_id(increment_message_uuid(self.letta_message_id), message_index),
|
||||
run_id=self.run_id,
|
||||
step_id=self.step_id,
|
||||
)
|
||||
@@ -306,7 +305,7 @@ class SimpleAnthropicStreamingInterface:
|
||||
run_id=self.run_id,
|
||||
step_id=self.step_id,
|
||||
)
|
||||
prev_message_type = tool_call_msg.message_type
|
||||
prev_message_type = tool_call_msg.message_type
|
||||
yield tool_call_msg
|
||||
|
||||
elif isinstance(content, BetaThinkingBlock):
|
||||
@@ -382,13 +381,11 @@ class SimpleAnthropicStreamingInterface:
|
||||
call_id = ctx.get("id")
|
||||
|
||||
if name in self.requires_approval_tools:
|
||||
if prev_message_type and prev_message_type != "approval_request_message":
|
||||
message_index += 1
|
||||
tool_call_msg = ApprovalRequestMessage(
|
||||
id=self.letta_message_id,
|
||||
id=increment_message_uuid(self.letta_message_id),
|
||||
tool_call=ToolCallDelta(name=name, tool_call_id=call_id, arguments=delta.partial_json),
|
||||
date=datetime.now(timezone.utc).isoformat(),
|
||||
otid=Message.generate_otid_from_id(self.letta_message_id, message_index),
|
||||
otid=Message.generate_otid_from_id(increment_message_uuid(self.letta_message_id), message_index),
|
||||
run_id=self.run_id,
|
||||
step_id=self.step_id,
|
||||
)
|
||||
@@ -404,7 +401,7 @@ class SimpleAnthropicStreamingInterface:
|
||||
run_id=self.run_id,
|
||||
step_id=self.step_id,
|
||||
)
|
||||
|
||||
prev_message_type = tool_call_msg.message_type
|
||||
yield tool_call_msg
|
||||
|
||||
elif isinstance(delta, BetaThinkingDelta):
|
||||
|
||||
Reference in New Issue
Block a user