AI-Engineer-Foundation / agent-protocol

Common interface for interacting with AI agents. The protocol is tech stack agnostic - you can use it with any framework for building agents.

Home Page:https://agentprotocol.ai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[bug] `list_agent_task*` endpoints on Python client are broken

Pwuts opened this issue · comments

Package: agent-protocol-client v1.0.2

The list_agent_task* endpoints on the AgentApi are broken:

  • list_agent_task_steps(task_id) returns ['steps', 'pagination'], because its _response_types_map declares the response as List[str]

  • list_agent_tasks_ids() returns ['tasks', 'pagination'], same issue as above

  • list_agent_task_artifacts(task_id) raises a parsing error, see below:

The TaskArtifactsListResponse spec prescribes a response format like { artifacts: Artifact[] }. The client library assumes it is just Artifact[], which causes a parsing error on the response of compliant endpoints.

The error occurs here:

if type(klass) == str:
if klass.startswith("List["):
sub_kls = re.match(r"List\[(.*)]", klass).group(1)
return [self.__deserialize(sub_data, sub_kls) for sub_data in data]
and is caused by ... for sub_data in data with data being an object like { 'artifacts': [...] }: it calls Artifact.parse_obj on the string artifacts, which fails.

Resulting stack trace:

    artifacts = await api_instance.list_agent_task_artifacts(task_id=task_id)
/home/user/.local/lib/python3.11/site-packages/agent_protocol_client/api_client.py:268: in __call_api
    return_data = self.deserialize(response_data, response_type)
/home/user/.local/lib/python3.11/site-packages/agent_protocol_client/api_client.py:341: in deserialize
    return self.__deserialize(data, response_type)
/home/user/.local/lib/python3.11/site-packages/agent_protocol_client/api_client.py:357: in __deserialize
    return [self.__deserialize(sub_data, sub_kls) for sub_data in data]
/home/user/.local/lib/python3.11/site-packages/agent_protocol_client/api_client.py:357: in <listcomp>
    return [self.__deserialize(sub_data, sub_kls) for sub_data in data]
/home/user/.local/lib/python3.11/site-packages/agent_protocol_client/api_client.py:378: in __deserialize
    return self.__deserialize_model(data, klass)
/home/user/.local/lib/python3.11/site-packages/agent_protocol_client/api_client.py:840: in __deserialize_model
    return klass.from_dict(data)
/home/user/.local/lib/python3.11/site-packages/agent_protocol_client/models/artifact.py:68: in from_dict
    return Artifact.parse_obj(obj)
------------------------------------------------

>   ???
E   pydantic.error_wrappers.ValidationError: 1 validation error for Artifact
E   __root__
E     Artifact expected dict not str (type=type_error)

pydantic/main.py:525: ValidationError