Skip to content

A task can't serve its own API to anything outside its sandbox #501

Closed

Description

@mastersingh24

What happens

A lot of agents are servers. They accept chat sessions, A2A calls, MCP requests or webhooks. When an agent like that runs as an AX Task on Agent Substrate, nothing outside the sandbox can reach it.

The reason is that Substrate's router only delivers requests to the runner, on port 80, and the runner only answers its own health checks. A request meant for the agent reaches the runner and stops there. The agent is running and listening, but only inside the sandbox.

Example

We run mast, an agent harness, as a Task. It serves its session API on 127.0.0.1:8484 inside the sandbox. From another pod in the cluster, a request through the router reaches the runner instead of mast:

$ curl -s -H "ate-target-actor: cred-test/demo-agent-01" \
    -H "Authorization: Bearer $TOKEN" \
    http://atenet-router.ate-system.svc.cluster.local/sessions
404 page not found

The 404 comes from the runner's probe listener, which only handles /healthz and /readyz (internal/metadata/server.go). There is no way to tell the runner that the task has an API of its own.

A second problem shows up once a task can be reached this way. When a request arrives for a suspended task, the router wakes it and waits for /readyz. The runner reports ready as soon as it is up, which can be before the agent's server is listening again, so the first request after a wake fails.

Proposed solution

Add an optional spec.http.port to the Task:

spec:
  http:
    port: 8484

When it's set, the runner forwards every request it doesn't handle itself to that port on localhost. It streams responses as they arrive (agents stream a lot) and passes connection upgrades through. The port can't be the runner's own port (80) or its metadata port (8099). /readyz also waits until something accepts connections on that port, so a request that wakes a task is held until the agent can answer it, rather than failing. Requests stay behind the router and whatever auth the agent itself enforces; nothing new is exposed outside the cluster.

We've been running this on our fork for a couple of weeks; it's what lets our triage agents receive incidents and follow-up questions while they scale to zero between them:

This is related to #454 and #430, which describe bigger designs for getting traffic into tasks (a gateway in ax-server, interactive clients). A port on the Task would be a small piece either of them could build on.

Activity

  1. self-assigned this
    on Oct 20, 2026
  2. rakyll commented on Oct 20, 2026

    @rakyll
    Member

    We need Substrate networking policies to be represented as YAML so we can apply them. We want to be 100% compatible to Substrate networking policies here not to diverge.

  3. mastersingh24 commented on Oct 30, 2026

    @mastersingh24
    ContributorAuthor

    Thanks. I think this one might have read as an egress issue (#449 is the egress one). This is about traffic coming into a task: another service in the cluster calling the agent's own server.

    Looking at it again, Substrate already covers most of it without anything new in AX. The router's CONNECT path can target any port in the actor; only plain HTTP requests default to port 80. So a client can reach an agent's server on, say, port 8484 by tunnelling through the router, and our runner pass-through isn't needed for that part.

    What's left for AX is waking up cleanly. Substrate's wakeup probe calls the runner's /readyz, which reports ready before the agent's own server is listening again. So the first request after a resume can fail, even though the router held it until the probe passed. A small fix would be to let a Task name the port its server listens on, and have the runner's /readyz wait until that port accepts connections. Another option is to point the ActorTemplate's wakeup probe at that port, if you'd rather keep it in Substrate's terms.

    Happy to narrow the issue to just that if it sounds right.

  4. rakyll commented on Nov 2, 2026

    @rakyll
    Member

    Duplicate of #549.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions