diff --git a/agents-api/agents_api/models/task/create_or_update_task.py b/agents-api/agents_api/models/task/create_or_update_task.py index af7e258d9..702e505ad 100644 --- a/agents-api/agents_api/models/task/create_or_update_task.py +++ b/agents-api/agents_api/models/task/create_or_update_task.py @@ -64,7 +64,7 @@ def create_or_update_task( data.metadata = data.metadata or {} data.input_schema = data.input_schema or {} - task_data = task_to_spec(data).model_dump(exclude_none=True, exclude_unset=True) + task_data = task_to_spec(data).model_dump(exclude_none=True, exclude_unset=True, mode="json") task_data.pop("task_id", None) task_data["created_at"] = utcnow().timestamp() diff --git a/agents-api/agents_api/models/task/create_task.py b/agents-api/agents_api/models/task/create_task.py index a44146c34..9affe0ead 100644 --- a/agents-api/agents_api/models/task/create_task.py +++ b/agents-api/agents_api/models/task/create_task.py @@ -55,7 +55,7 @@ def create_task( # Prepares the update data by filtering out None values and adding user_id and developer_id. columns, values = cozo_process_mutate_data( { - **task_spec.model_dump(exclude_none=True, exclude_unset=True), + **task_spec.model_dump(exclude_none=True, exclude_unset=True, mode="json"), "task_id": str(task_id), "agent_id": str(agent_id), } diff --git a/agents-api/agents_api/routers/agents/create_agent.py b/agents-api/agents_api/routers/agents/create_agent.py index 06e8f17cd..2e1c4df0a 100644 --- a/agents-api/agents_api/routers/agents/create_agent.py +++ b/agents-api/agents_api/routers/agents/create_agent.py @@ -4,13 +4,12 @@ from fastapi import Depends from starlette.status import HTTP_201_CREATED -from ...models.agent.create_agent import create_agent as create_agent_query - from ...autogen.openapi_model import ( CreateAgentRequest, ResourceCreatedResponse, ) from ...dependencies.developer_id import get_developer_id +from ...models.agent.create_agent import create_agent as create_agent_query from .router import router diff --git a/agents-api/tests/test_execution_workflow.py b/agents-api/tests/test_execution_workflow.py index b6394f1bc..42ca4cd78 100644 --- a/agents-api/tests/test_execution_workflow.py +++ b/agents-api/tests/test_execution_workflow.py @@ -441,6 +441,63 @@ async def _( assert result["hello"] == data.input["test"] +@test("workflow: tool call api_call") +async def _( + client=cozo_client, + developer_id=test_developer_id, + agent=test_agent, +): + data = CreateExecutionRequest(input={"test": "input"}) + + task = create_task( + developer_id=developer_id, + agent_id=agent.id, + data=CreateTaskRequest( + **{ + "name": "test task", + "description": "test task about", + "input_schema": {"type": "object", "additionalProperties": True}, + "tools": [ + { + "type": "api_call", + "name": "hello", + "api_call": { + "method": "GET", + "url": "https://httpbin.org/get", + }, + } + ], + "main": [ + { + "tool": "hello", + "params": {"test": "_.test"}, + }, + { + "evaluate": {"hello": "_.json()['args']['test']"}, + } + ], + } + ), + client=client, + ) + + async with patch_testing_temporal() as (_, mock_run_task_execution_workflow): + execution, handle = await start_execution( + developer_id=developer_id, + task_id=task.id, + data=data, + client=client, + ) + + assert handle is not None + assert execution.task_id == task.id + assert execution.input == data.input + mock_run_task_execution_workflow.assert_called_once() + + result = await handle.result() + assert result["hello"] == data.input["test"] + + @test("workflow: tool call integration dummy") async def _( client=cozo_client,