Skip to content

Commit 6a2b862

Browse files
Merge pull request #68 from mainframecomputer/MFE-562-preexecute-in-tool-loop
Mfe 562 preexecute in tool loop
2 parents a1a80de + 9ba754d commit 6a2b862

4 files changed

Lines changed: 8 additions & 3 deletions

File tree

packages/python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "mainframe-orchestra"
3-
version = "0.0.29"
3+
version = "0.0.30"
44
description = "Mainframe-Orchestra is a lightweight, open-source agentic framework for building LLM based pipelines and self-orchestrating multi-agent teams"
55
authors = [
66
"Mainframe Computer Inc. <hi@mainfra.me>",

packages/python/src/mainframe_orchestra/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44
# Copyright 2024 Mainframe-Orchestra Contributors. Licensed under Apache License 2.0.
55

6-
__version__ = "0.0.29"
6+
__version__ = "0.0.30"
77

88
import importlib
99

packages/python/src/mainframe_orchestra/orchestration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ async def nested_callback(result):
199199
event_queue=event_queue,
200200
messages=messages,
201201
tool_summaries=tool_summaries,
202+
pre_execute=kwargs.get("pre_execute")
202203
)
203204

204205
# Generate a delegation result event after task completion

packages/python/src/mainframe_orchestra/task.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,10 @@ def hash_tool_call(tool_call: dict) -> str:
609609
logger.debug(f"Starting iteration {iteration_count + 1}/{MAX_ITERATIONS}")
610610
iteration_count += 1
611611

612+
# Call pre_execute at the beginning of each tool loop iteration
613+
if pre_execute:
614+
await pre_execute({"agent_id": self.agent_id})
615+
612616
# Include tool results in context if we have any
613617
context_parts = []
614618
if self.context:
@@ -757,7 +761,7 @@ def hash_tool_call(tool_call: dict) -> str:
757761

758762
initial_prompt = (
759763
f"Given the task instruction: '{self.instruction}' and the planned tool calls: {json.dumps(response_data['tool_calls'], indent=2)}, "
760-
"please provide an initial response explaining your planned approach before executing the tools."
764+
"please provide an initial response explaining your planned approach. Provide only a conversational response. You cannot call tools *in* this response, you will be calling them after this response, so don't attempt to call them here. Do not attempt to fully answer the task, and don't ask questions because this will be immediately followed by tool calls."
761765
)
762766

763767
original_messages = self.messages

0 commit comments

Comments
 (0)