[S2] Agent.run(tasks=[Agent.Task(...)]) raises TypeError: Object of type Task is not JSON serializable · Issue #1108 · aixplain/aiXplain · GitHub
Skip to content

[S2] Agent.run(tasks=[Agent.Task(...)]) raises TypeError: Object of type Task is not JSON serializable #1108

Open

Description

@aix-ahmet

Source: external black-box user audit of PyPI aixplain 0.2.48 (finding #42). Verified offline against development @ e9f7061; the aixplain/ package there is byte-identical to main/0.2.48, so this is present on all branches.

Problem

Using the documented type in the documented per-run field fails:

ag.run("...", tasks=[aix.Agent.Task(name="t", description="d", expected_output="o")])
# TypeError: Object of type Task is not JSON serializable

tasks=[t.to_dict()] works, and construct-time Agent(tasks=[t]) works. Only the per-run path is broken.

Evidence

aixplain/v2/agent.py:2363-2366: the catch-all kwargs forwarder puts raw kwargs into the payload; Task objects reach json.dumps. The construct path serialises them via to_dict().

Suggested fix

payload["tasks"] = [t.to_dict() if isinstance(t, Task) else t for t in tasks] in build_run_payload, plus a unit test.

Activity

  1. added
    bugSomething isn't working
    severity-2High: feature broken or misleading for common usage
    on Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingseverity-2High: feature broken or misleading for common usage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions