Skip to content

Commit cad0f8d

Browse files
Merge pull request #72 from mainframecomputer/feature/task-context-propagation
Feature/task context propagation
2 parents 0d51b70 + 5af9768 commit cad0f8d

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

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.31"
3+
version = "0.0.32"
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. <[email protected]>",

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.31"
6+
__version__ = "0.0.32"
77

88
import importlib
99

packages/python/src/mainframe_orchestra/orchestration.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ async def conduct_tool(
4646
messages = kwargs.get("messages", [])
4747
current_time = datetime.now().isoformat()
4848

49+
# Get the parent task's context if available
50+
parent_context = kwargs.get("parent_context")
51+
4952
# Track agent iterations
5053
agent_call_counts = {} # Track {agent_id: count}
5154

@@ -108,6 +111,7 @@ async def conduct_tool(
108111
f"You are {target_agent.role}. "
109112
f"Your goal is {target_agent.goal}"
110113
f"{' Your attributes are: ' + target_agent.attributes if target_agent.attributes and target_agent.attributes.strip() else ''}"
114+
f"{'\nAdditional context: ' + parent_context if parent_context else ''}"
111115
).strip(),
112116
}
113117
]
@@ -199,7 +203,8 @@ async def nested_callback(result):
199203
event_queue=event_queue,
200204
messages=messages,
201205
tool_summaries=tool_summaries,
202-
pre_execute=kwargs.get("pre_execute")
206+
pre_execute=kwargs.get("pre_execute"),
207+
context=parent_context # Pass the parent context to the delegated task
203208
)
204209

205210
# Generate a delegation result event after task completion

packages/python/src/mainframe_orchestra/task.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -847,14 +847,13 @@ async def callback_wrapper(event):
847847

848848
if tool_name == "conduct_tool":
849849
# Store callback-related parameters separately
850-
special_params.update(
851-
{
852-
"callback": callback,
853-
"thread_id": self.thread_id,
854-
"event_queue": self.event_queue,
855-
"pre_execute": pre_execute,
856-
}
857-
)
850+
special_params.update({
851+
"callback": callback,
852+
"thread_id": self.thread_id,
853+
"event_queue": self.event_queue,
854+
"pre_execute": pre_execute,
855+
"parent_context": self.context, # Pass the parent task's context
856+
})
858857

859858
# Log only the serializable parameters
860859
logger.info(

0 commit comments

Comments
 (0)