Revert "Merge from main"

This reverts commit b8206a85d7.
This commit is contained in:
Dmytro Struk
2025-11-11 18:44:25 -08:00
Unverified
parent b8206a85d7
commit 85fcd230bf
231 changed files with 4138 additions and 19654 deletions
+13 -62
View File
@@ -100,43 +100,17 @@ async def test_executor_sync_execution(executor):
assert len(agents) > 0, "No agent entities found for testing"
agent_id = agents[0].id
# Use metadata.entity_id for routing
# Use simplified routing: model = entity_id
request = AgentFrameworkRequest(
metadata={"entity_id": agent_id},
model=agent_id, # Model IS the entity_id
input="test data",
stream=False,
)
response = await executor.execute_sync(request)
# Response model should be 'devui' when not specified
assert response.model == "devui"
assert response.object == "response"
assert len(response.output) > 0
assert response.usage.total_tokens > 0
@pytest.mark.skipif(not os.getenv("OPENAI_API_KEY"), reason="requires OpenAI API key")
async def test_executor_sync_execution_with_model(executor):
"""Test synchronous execution with model field specified."""
entities = await executor.discover_entities()
# Find an agent entity to test with
agents = [e for e in entities if e.type == "agent"]
assert len(agents) > 0, "No agent entities found for testing"
agent_id = agents[0].id
# Use metadata.entity_id for routing AND specify a model
request = AgentFrameworkRequest(
metadata={"entity_id": agent_id},
model="custom-model-name",
input="test data",
stream=False,
)
response = await executor.execute_sync(request)
# Response model should reflect the specified model
assert response.model == "custom-model-name"
# With simplified routing, response.model reflects the actual agent_id
assert response.model == agent_id
assert response.object == "response"
assert len(response.output) > 0
assert response.usage.total_tokens > 0
@@ -152,9 +126,9 @@ async def test_executor_streaming_execution(executor):
assert len(agents) > 0, "No agent entities found for testing"
agent_id = agents[0].id
# Use metadata.entity_id for routing
# Use simplified routing: model = entity_id
request = AgentFrameworkRequest(
metadata={"entity_id": agent_id},
model=agent_id, # Model IS the entity_id
input="streaming test",
stream=True,
)
@@ -181,14 +155,14 @@ async def test_executor_invalid_entity_id(executor):
async def test_executor_missing_entity_id(executor):
"""Test get_entity_id returns metadata.entity_id."""
"""Test get_entity_id returns model field (simplified routing)."""
request = AgentFrameworkRequest(
metadata={"entity_id": "my_agent"},
model="my_agent",
input="test",
stream=False,
)
# entity_id is extracted from metadata
# With simplified routing, model field IS the entity_id
entity_id = request.get_entity_id()
assert entity_id == "my_agent"
@@ -238,29 +212,6 @@ def test_executor_parse_raw_falls_back_to_string():
assert parsed == "hi there"
def test_executor_parse_stringified_json_workflow_input():
"""Stringified JSON workflow input (from frontend JSON.stringify) is correctly parsed."""
from pydantic import BaseModel
class WorkflowInput(BaseModel):
input: str
metadata: dict | None = None
executor = AgentFrameworkExecutor(EntityDiscovery(None), MessageMapper())
start_executor = _DummyStartExecutor(handlers={WorkflowInput: lambda *_: None})
workflow = _DummyWorkflow(start_executor)
# Simulate frontend sending JSON.stringify({"input": "testing!", "metadata": {"key": "value"}})
stringified_json = '{"input": "testing!", "metadata": {"key": "value"}}'
parsed = executor._parse_raw_workflow_input(workflow, stringified_json)
# Should parse into WorkflowInput object
assert isinstance(parsed, WorkflowInput)
assert parsed.input == "testing!"
assert parsed.metadata == {"key": "value"}
async def test_executor_handles_non_streaming_agent():
"""Test executor can handle agents with only run() method (no run_stream)."""
from agent_framework import AgentRunResponse, AgentThread, ChatMessage, Role, TextContent
@@ -294,9 +245,9 @@ async def test_executor_handles_non_streaming_agent():
entity_info = await discovery.create_entity_info_from_object(agent, source="test")
discovery.register_entity(entity_info.id, entity_info, agent)
# Execute non-streaming agent (use metadata.entity_id for routing)
# Execute non-streaming agent (use simplified routing)
request = AgentFrameworkRequest(
metadata={"entity_id": entity_info.id},
model=entity_info.id, # Model IS the entity_id
input="hello",
stream=True, # DevUI always streams
)
@@ -338,9 +289,9 @@ class StreamingAgent:
entities = await executor.discover_entities()
if entities:
# Test sync execution (use metadata.entity_id for routing)
# Test sync execution (use simplified routing)
request = AgentFrameworkRequest(
metadata={"entity_id": entities[0].id},
model=entities[0].id, # Model IS the entity_id
input="test input",
stream=False,
)