Skip to content

Emit ax.task.state_changed events for task debugging and Substrate timeline correlation #675

Description

@JeffLuoo

Problem

ax describe only tells you what a task is doing right now, and once a task is deleted it is just NotFound. RPC traces do not fill that gap: they are off by default, sampled at 10% when enabled, and cover gRPC calls only, not runner outcome callbacks or state diffs.

Agent Substrate solves this for actors with ate.actor.state_changed and ate.actor.crashed events, which go to stdout even without a collector. AX has nothing like that for tasks, so two things are missing when debugging:

  1. Why a task stopped: when a command finishes or fails, AX suspends the actor and logs nothing. To Substrate that looks just like ax suspend, and once the task is deleted, its outcome and exit code are gone.
  2. Task states Substrate does not see: Substrate only tracks the actor, not AX states like Queued, Terminating, or Deleted.

Mapping ax.task.id onto Substrate events can live on the Substrate side once immutable actor labels in agent-substrate/substrate#3208 propagate to ate.actor.*. Even with that, Substrate still does not know command outcomes or AX-only phases.

Example

Say a task gets created, resumed, suspended, and resumed again, then gets stuck and someone deletes it. If you join ax.task.state_changed with Substrate's ate.actor.state_changed on ate.actor.uid, one query gives you the whole story:

18:24:14.168Z  ax.task.state_changed   task=t5-fail  none -> Queued                gen=1
18:24:14.358Z  ax.task.state_changed   task=t5-fail  Queued -> Provisioned         gen=2   ate.actor.uid=dbafc5d7...
18:24:14-28    ate.actor.state_changed actor=dbafc5d7... suspended -> resuming -> running -> suspending -> suspended -> resuming -> running
18:28:42.476Z  ax.task.state_changed   task=t5-fail  Provisioned -> Terminating    gen=9   ate.actor.uid=dbafc5d7...
18:28:42.49xZ  ate.actor.state_changed actor=dbafc5d7... deleting -> deleted
18:28:42.710Z  ax.task.state_changed   task=t5-fail  Terminating -> Deleted        gen=10  ate.actor.uid=dbafc5d7...

You can tell right away that Substrate ran the actor fine without crashing, ax-server got no outcome back before the delete, and dbafc5d7... stays tied to this task ID even after the task is gone.

Proposal

Emit ax.task.state_changed (OTLP logs, with stdout JSON as a fallback) whenever a task write commits and changes phase, outcome, or ate.actor.uid:

  • Only track AX-owned states (Queued, Provisioned, Completed, Failed, Cancelled, Terminating, Deleted). Live actor states (Working, Suspended, Crashed) stay in ate.actor.state_changed.
  • Use the commit time as the event timestamp, and include ax.task.generation, ax.task.id, ate.actor.uid, ax.task.phase, ax.task.previous_phase, ax.task.outcome, ax.task.previous_outcome, and ax.task.exit_code.
  • Emit after the write commits, best effort. Failed or no-op writes emit nothing, and telemetry errors do not break task writes.

Related: #13, draft PR in #665.

Activity

  1. self-assigned this
    on Nov 20, 2026
  2. added theissue type on Nov 20, 2026
  3. JeffLuoo commented on Nov 20, 2026

    @JeffLuoo
    CollaboratorAuthor

    @mayawang as we discussed in the PR, create an issue for discussion

  4. JeffLuoo commented on Nov 23, 2026

    @JeffLuoo
    CollaboratorAuthor

    also cc - @rakyll WDYT for having the state events for task like what we have for actor in substrate?

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

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions