Add multi-pattern orchestrator with plan-then-execute and supervisor (#739)

Introduce an agent orchestrator service that supports three
execution patterns (ReAct, plan-then-execute, supervisor) with
LLM-based meta-routing to select the appropriate pattern and task
type per request. Update the agent schema to support
orchestration fields (correlation, sub-agents, plan steps) and
remove legacy response fields (answer, thought, observation).
This commit is contained in:
cybermaggedon 2026-03-31 00:32:49 +01:00 committed by GitHub
parent 7af1d60db8
commit 849987f0e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 3006 additions and 172 deletions

View file

@ -87,10 +87,11 @@ def sample_message_data():
"history": []
},
"AgentResponse": {
"answer": "Machine learning is a subset of AI.",
"chunk_type": "answer",
"content": "Machine learning is a subset of AI.",
"end_of_message": True,
"end_of_dialog": True,
"error": None,
"thought": "I need to provide information about machine learning.",
"observation": None
},
"Metadata": {
"id": "test-doc-123",

View file

@ -212,10 +212,11 @@ class TestAgentMessageContracts:
# Test required fields
response = AgentResponse(**response_data)
assert hasattr(response, 'answer')
assert hasattr(response, 'chunk_type')
assert hasattr(response, 'content')
assert hasattr(response, 'end_of_message')
assert hasattr(response, 'end_of_dialog')
assert hasattr(response, 'error')
assert hasattr(response, 'thought')
assert hasattr(response, 'observation')
def test_agent_step_schema_contract(self):
"""Test AgentStep schema contract"""

View file

@ -188,12 +188,10 @@ class TestAgentTranslatorCompletionFlags:
# Arrange
translator = TranslatorRegistry.get_response_translator("agent")
response = AgentResponse(
answer="4",
error=None,
thought=None,
observation=None,
chunk_type="answer",
content="4",
end_of_message=True,
end_of_dialog=True
end_of_dialog=True,
)
# Act
@ -201,7 +199,7 @@ class TestAgentTranslatorCompletionFlags:
# Assert
assert is_final is True, "is_final must be True when end_of_dialog=True"
assert response_dict["answer"] == "4"
assert response_dict["content"] == "4"
assert response_dict["end_of_dialog"] is True
def test_agent_translator_is_final_with_end_of_dialog_false(self):
@ -212,12 +210,10 @@ class TestAgentTranslatorCompletionFlags:
# Arrange
translator = TranslatorRegistry.get_response_translator("agent")
response = AgentResponse(
answer=None,
error=None,
thought="I need to solve this.",
observation=None,
chunk_type="thought",
content="I need to solve this.",
end_of_message=True,
end_of_dialog=False
end_of_dialog=False,
)
# Act
@ -225,31 +221,9 @@ class TestAgentTranslatorCompletionFlags:
# Assert
assert is_final is False, "is_final must be False when end_of_dialog=False"
assert response_dict["thought"] == "I need to solve this."
assert response_dict["content"] == "I need to solve this."
assert response_dict["end_of_dialog"] is False
def test_agent_translator_is_final_fallback_with_answer(self):
"""
Test that AgentResponseTranslator returns is_final=True
when answer is present (fallback for legacy responses).
"""
# Arrange
translator = TranslatorRegistry.get_response_translator("agent")
# Legacy response without end_of_dialog flag
response = AgentResponse(
answer="4",
error=None,
thought=None,
observation=None
)
# Act
response_dict, is_final = translator.from_response_with_completion(response)
# Assert
assert is_final is True, "is_final must be True when answer is present (legacy fallback)"
assert response_dict["answer"] == "4"
def test_agent_translator_intermediate_message_is_not_final(self):
"""
Test that intermediate messages (thought/observation) return is_final=False.
@ -259,12 +233,10 @@ class TestAgentTranslatorCompletionFlags:
# Test thought message
thought_response = AgentResponse(
answer=None,
error=None,
thought="Processing...",
observation=None,
chunk_type="thought",
content="Processing...",
end_of_message=True,
end_of_dialog=False
end_of_dialog=False,
)
# Act
@ -275,12 +247,10 @@ class TestAgentTranslatorCompletionFlags:
# Test observation message
observation_response = AgentResponse(
answer=None,
error=None,
thought=None,
observation="Result found",
chunk_type="observation",
content="Result found",
end_of_message=True,
end_of_dialog=False
end_of_dialog=False,
)
# Act
@ -302,10 +272,6 @@ class TestAgentTranslatorCompletionFlags:
content="",
end_of_message=True,
end_of_dialog=True,
answer=None,
error=None,
thought=None,
observation=None
)
# Act