Skip to content

Tasks have no network access on current Agent Substrate because ax never creates an egress policy #449

Done

Description

@mastersingh24

On Agent Substrate v0.2.0 and later, an actor can't open outbound connections until it has an egress policy. ax never creates one, and there's nothing on a Task or Workspace that would let you ask for one, so every task ends up with no network at all. Anything that calls a model API, clones a repo at runtime, or installs a package just hangs or fails.

Before the September restructure, the Gateway resource took care of this (see #350). Since it was removed there's no way to do it through ax.

Example (Agent Substrate v0.3.0, ax main at ac23328, agentgateway egress dataplane):

apiVersion: ax.io/v1alpha1
kind: Task
metadata:
  name: net-test
  atespace: default
spec:
  image: "<runner image>@sha256:..."
  command: ["sh", "-c", "sleep infinity"]
  debug: true
$ ax ssh net-test -- openssl s_client -connect www.google.com:443 -brief
write:errno=104

The connection is reset. If I add a policy for the actor by hand with Substrate's own CLI, it starts working right away:

# policy.yaml
metadata: {atespace: default, name: default}
rules:
  - https:
      hostnames: [www.google.com, generativelanguage.googleapis.com]
      ports: {numbers: [443]}
$ kubectl ate create egress-policy net-test -a default -f policy.yaml

That works for a one-off test, but it means a second tool, access to the Substrate API, and remembering to do it for every task after its actor exists.

Suggested fix

  • Add an optional egress section to TaskSpec (or to Workspace, if it's meant to be shared): a list of allowed hostnames and ports. Have the reconciler call CreateActorEgressPolicy right after EnsureActor, before the first resume. Since tasks are immutable, create-only is enough.
  • Add an ax-server flag for a default policy applied to tasks that don't set one, for clusters that want open egress. Keep the default closed so this doesn't bring back the problem in Missing referenced gateway grants wildcard egress and starts the task #350.

Two Substrate details we ran into, in case they help whoever picks this up. On v0.3.0, tlsPassthrough rules are accepted but ignored by the gateway; that's fixed on Substrate main in 6c75a41f. Use https rules on v0.3.0. Also, the default Envoy egress dataplane didn't forward allowed TLS traffic for us, while the agentgateway dataplane did.

Activity

  1. bdubs00 commented on Oct 18, 2026

    @bdubs00

    I have a change for this on my fork, ready for review: main...bdubs00:ax:feat/task-egress-policy

    It follows the fix suggested above. spec.egress on the Task lists the connections the task may open, as rules with one protocol each, http, https, or tls, with hostnames and optional ports; a rule without ports gets the default port of its protocol. The controller writes the rules to the actor's egress policy right after EnsureActor and before the first resume, which is the window that the suspended-by-default creation already provides, so the policy is in place before the task's first request. Tasks are immutable, so the policy is created once. The API server validates the section at apply time, as it validates names, and a task without spec.egress behaves as before. A refused policy fails the task with EgressPolicyFailed; an unavailable Substrate leaves it pending. Credential injection is left to #475, and the server flag for a default policy is left out so the change stays small; both build on this field.

    make test passes with new tests for the validation, the mapping, the order of the calls, and the failures, and go mod tidy is clean. I ran it on a single-node k3s cluster with Agent Substrate v0.4.0. tasks created with spec.egress got their policies before their first resume, including child tasks that a running task created through the API with the same section, and an end-to-end suite that depends on task networking passed on top of it.

    Pull requests are limited to collaborators, so I cannot open one. If this is wanted, a maintainer can pick the branch up as is, or grant me access and I will open the pull request. I have already signed a CLA.

  2. mayawang commented on Oct 19, 2026

    @mayawang
    Collaborator

    Thanks @bdubs00, this is a solid change. #499 is a draft that adds egress to the API too, so let's line the two up before opening a PR, so we land one shape.

  3. rakyll commented on Nov 25, 2026

    @rakyll
    Member

    Fixed: the Gateway resource configures the actor's EgressPolicy (#567, #585, #588).

    We are closing this as part of a cleanup after the significant changes in v0.4.0, because it is probably obsolete or out of scope now. If you think this is a mistake, please reopen it (or leave a comment if you can't reopen it).

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions