autobyteus 1.1.7__py3-none-any.whl → 1.1.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,10 +16,10 @@ logger = logging.getLogger(__name__)
16
16
 
17
17
  class ToolResultEventHandler(AgentEventHandler):
18
18
  """
19
- Handles ToolResultEvents. It immediately processes and notifies for each
20
- individual tool result. If a multi-tool call turn is active, it accumulates
21
- these processed results until the turn is complete, then sends a single
22
- aggregated message to the LLM.
19
+ Handles ToolResultEvents. It processes and notifies for each individual tool
20
+ result as it arrives. If a multi-tool call turn is active, it accumulates
21
+ these results until the turn is complete, re-orders them to match the original
22
+ invocation sequence, and then sends a single aggregated message to the LLM.
23
23
  """
24
24
  def __init__(self):
25
25
  logger.info("ToolResultEventHandler initialized.")
@@ -28,8 +28,8 @@ class ToolResultEventHandler(AgentEventHandler):
28
28
  processed_events: List[ToolResultEvent],
29
29
  context: 'AgentContext'):
30
30
  """
31
- Aggregates a list of PRE-PROCESSED tool results into a single message and
32
- dispatches it to the LLM.
31
+ Aggregates a list of PRE-PROCESSED and ORDERED tool results into a single
32
+ message and dispatches it to the LLM.
33
33
  """
34
34
  agent_id = context.agent_id
35
35
 
@@ -133,9 +133,29 @@ class ToolResultEventHandler(AgentEventHandler):
133
133
  if not active_turn.is_complete():
134
134
  return
135
135
 
136
- # If all results are in, dispatch them to the LLM and clean up the turn state.
137
- logger.info(f"Agent '{agent_id}': All tool results for the turn collected. Aggregating for LLM.")
138
- await self._dispatch_aggregated_results_to_llm(active_turn.results, context)
136
+ # If all results are in, re-order them and then dispatch to the LLM.
137
+ logger.info(f"Agent '{agent_id}': All tool results for the turn collected. Re-ordering to match invocation sequence.")
138
+
139
+ # --- NEW RE-ORDERING LOGIC ---
140
+ results_by_id = {res.tool_invocation_id: res for res in active_turn.results}
141
+ sorted_results: List[ToolResultEvent] = []
142
+ for original_invocation in active_turn.invocations:
143
+ result = results_by_id.get(original_invocation.id)
144
+ if result:
145
+ sorted_results.append(result)
146
+ else:
147
+ # This should not happen if the logic is correct, but it's a good safeguard.
148
+ logger.error(f"Agent '{agent_id}': Missing result for invocation ID '{original_invocation.id}' during re-ordering.")
149
+ # Add a synthetic error result to maintain sequence length.
150
+ sorted_results.append(ToolResultEvent(
151
+ tool_name=original_invocation.name,
152
+ result=None,
153
+ error=f"Critical Error: Result for this tool call was lost.",
154
+ tool_invocation_id=original_invocation.id
155
+ ))
156
+
157
+ await self._dispatch_aggregated_results_to_llm(sorted_results, context)
139
158
 
140
159
  context.state.active_multi_tool_call_turn = None
141
160
  logger.info(f"Agent '{agent_id}': Multi-tool call turn state has been cleared.")
161
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: autobyteus
3
- Version: 1.1.7
3
+ Version: 1.1.8
4
4
  Summary: Multi-Agent framework
5
5
  Home-page: https://github.com/AutoByteus/autobyteus
6
6
  Author: Ryan Zheng
@@ -36,7 +36,7 @@ autobyteus/agent/handlers/llm_complete_response_received_event_handler.py,sha256
36
36
  autobyteus/agent/handlers/llm_user_message_ready_event_handler.py,sha256=4WgDXUY4rmjpP44X2THKMAt2NpAZ5GukPqVNmLt6XJM,9064
37
37
  autobyteus/agent/handlers/tool_execution_approval_event_handler.py,sha256=Tda_LrlIPbEwVzf1I6u4Vb9sPmAbGQRqT_2-Q9ukLhw,4489
38
38
  autobyteus/agent/handlers/tool_invocation_request_event_handler.py,sha256=AjNGQgRCQkjXvYThd_AaPj0Lzh1adEkhYJO83alxVAY,10957
39
- autobyteus/agent/handlers/tool_result_event_handler.py,sha256=MmT567LCZ60sK0fgeULCR0wM7PIJEAsRESCdDZNhwC8,7292
39
+ autobyteus/agent/handlers/tool_result_event_handler.py,sha256=wecvtww_MuS1ekv_WexWGlR11bP96N46dK6uoWkXpHo,8370
40
40
  autobyteus/agent/handlers/user_input_message_event_handler.py,sha256=WBV_yFILqEEGbwhzPxKRKdTZcbJosvRIXAs8m1jOHi4,4937
41
41
  autobyteus/agent/hooks/__init__.py,sha256=a1do0Ribb2Hpf9t0Xqxhf3Ls7R6EQuWJtfTGQK7VjUM,495
42
42
  autobyteus/agent/hooks/base_phase_hook.py,sha256=7JU3FgPzX06Yg6eJgB4GXzXcaWTpOcEMmyw5Ku0mwJk,2040
@@ -465,7 +465,7 @@ autobyteus/workflow/streaming/workflow_stream_event_payloads.py,sha256=jv1bVYg-7
465
465
  autobyteus/workflow/streaming/workflow_stream_events.py,sha256=75P29jNgcL7Go7D9wVz236KTwPfmqc5K7hUvVnc94K0,2221
466
466
  autobyteus/workflow/utils/__init__.py,sha256=SzaMZHnJBIJKcT_r-HOeyIcuxzRu2bGeFkOcMLJaalk,222
467
467
  autobyteus/workflow/utils/wait_for_idle.py,sha256=FgHtz59DN0eg8Na1PkkVR55Ihdd2e5Gn_mr7RVHl4qI,2001
468
- autobyteus-1.1.7.dist-info/licenses/LICENSE,sha256=Ompok_c8HRsXRwmax-pGR9OZRRxZC9RPp4JB6eTJd0M,1360
468
+ autobyteus-1.1.8.dist-info/licenses/LICENSE,sha256=Ompok_c8HRsXRwmax-pGR9OZRRxZC9RPp4JB6eTJd0M,1360
469
469
  examples/__init__.py,sha256=BtTQJ6yeHyksK5GC3kfN6RFR6Gcrwq1TBmp6FIIj3Z8,40
470
470
  examples/discover_phase_transitions.py,sha256=NiFK_XzDCpWwmNsQqf0Ou2w6L5bofKIKODq7sH5uPzk,3679
471
471
  examples/run_browser_agent.py,sha256=tpBJGIYYvVsNZAUo_WsZbhV_8fdeORUoHlQ8uQvnXPM,11737
@@ -476,7 +476,7 @@ examples/run_mcp_list_tools.py,sha256=-dOM-7xyyDM2gp5e_8KZVGbX5ZxWqFQB9l-fHfR8Xx
476
476
  examples/run_poem_writer.py,sha256=wJsT4ZHwXw3MbPAESwyCkAMWWYt7KH5BLhEDQxA06XM,13145
477
477
  examples/run_sqlite_agent.py,sha256=wy1Mp_F7RR0WmvfmxsPLG9JFPi6SpTVd0x_Ep76bUQ8,13159
478
478
  examples/agent_team/__init__.py,sha256=WIg0HENp1TUClJ3p2gIRn0C-VW9Qr7Ttqtedr4xQ3Jo,51
479
- autobyteus-1.1.7.dist-info/METADATA,sha256=pgphbfB80cOcXlJd43NMVhIxaSSqOdJilDhTdo2ZyhE,10173
480
- autobyteus-1.1.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
481
- autobyteus-1.1.7.dist-info/top_level.txt,sha256=vNmK1Y8Irbc0iDPdRtr9gIx5eLM-c2v1ntItkzICzHU,20
482
- autobyteus-1.1.7.dist-info/RECORD,,
479
+ autobyteus-1.1.8.dist-info/METADATA,sha256=cvBLfLpv5ukmQrFsn7HL9P13ZIOoUNzhpeOXfRZMC0g,10173
480
+ autobyteus-1.1.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
481
+ autobyteus-1.1.8.dist-info/top_level.txt,sha256=vNmK1Y8Irbc0iDPdRtr9gIx5eLM-c2v1ntItkzICzHU,20
482
+ autobyteus-1.1.8.dist-info/RECORD,,