mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-09-30 12:43:16 +00:00
fix: Dont return another no-op tc if no-op already in state (#1011)
This commit is contained in:
parent
c0f17d32d8
commit
f2dc5950f6
1 changed files with 11 additions and 0 deletions
|
|
@ -38,12 +38,23 @@ def check_if_confirming_completion(messages: list[AnyMessage]) -> bool:
|
|||
return False
|
||||
|
||||
|
||||
def check_if_no_op(messages: list[AnyMessage]) -> bool:
|
||||
for msg in messages:
|
||||
if msg.type == "tool" and msg.name == "no_op":
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@after_model
|
||||
def ensure_no_empty_msg(state: AgentState, runtime: Runtime) -> dict[str, Any] | None:
|
||||
last_msg = state["messages"][-1]
|
||||
has_contents = bool(last_msg.text())
|
||||
has_tool_calls = bool(last_msg.tool_calls)
|
||||
if not has_tool_calls and not has_contents:
|
||||
messages_since_last_human = get_every_message_since_last_human(state)
|
||||
if check_if_no_op(messages_since_last_human):
|
||||
return None
|
||||
|
||||
tc_id = str(uuid4())
|
||||
last_msg.tool_calls = [{"name": "no_op", "args": {}, "id": tc_id}]
|
||||
no_op_tool_msg = ToolMessage(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue