Skip to content

Task results are dropped: sidecar's /task-result callback has no platform route #43

Open

Description

@michaelzwang13

Problem

backend/agent-runtime/server.py:116 POSTs every completed task to {PLATFORM_GATEWAY_URL}/task-result with the agent's bearer token. backend/app/routers/gateway.py has no such route, so the call 404s. The sidecar doesn't check the response, so the failure is silent.

The only copy of a result is the sidecar's in-memory _state["last_result"]. It holds only the latest task and is lost on container restart. Nobody can see what an AI employee actually did: not the UI, not the PR watcher, not someone debugging a review that never posted.

Why it went unnoticed

The sidecar and the platform are each tested in isolation, mocking the other side (tests/test_agent_runtime.py:174: # Patch the platform callback too). Nothing asserted that the sidecar's callback URL is a real platform route.

Evidence

A contract test on branch fix/task-result-callback (backend/tests/test_task_result_contract.py) captures the exact request the sidecar emits and replays it against the platform app:

AssertionError: sidecar POSTs task results to /gateway/task-result, but the platform has no such route
assert 404 != 404

Scope

  • agent_tasks table (migration + schema.sql): task_id, agent_id, instruction, metadata, status (dispatched → success / failed / cancelled), result, error, timestamps
  • Dispatcher writes a dispatched row before POSTing to the sidecar
  • POST /gateway/task-result, agent-authed, accepted only for the caller's own task_id
  • Sidecar reports failures and cancellations too, not just successes
  • User-facing read endpoint (e.g. GET /agents/{id}/tasks)

Open design questions

  • Should reporting a result go through require_action, or be allowed for any authenticated agent reporting on its own task?
  • Should the read endpoint return task history, or only the latest task?

Done when

The contract test passes, and a task dispatched in compose mode shows up with its final status and result after the container restarts.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions