Skip to content

fix(a2a): route active A2A reads and HasPending through the job supervisor (#693) - #721

Merged
edenreich merged 1 commit into
mainfrom
fix/a2a-status-bar-single-source-693
Jul 2, 2026
Merged

edenreich merged 1 commit into
mainfrom
fix/a2a-status-bar-single-source-693

Conversation

@edenreich

Copy link
Copy Markdown
Contributor

Summary

Closes #693.

A2A tasks were dual-tracked: the submit path registered each task in both the jobs.Supervisor (which the status-bar indicator counts via CountRunningJobs) and the A2ATaskTracker polling set (which the /tasks active list and HasPending read via GetAllPollingTasks). The two were cleaned up by independent paths and could diverge, so a running A2A task could be missing from the status-bar indicator while still showing in /tasks.

This makes the jobs.Supervisor the single source of truth for A2A liveness (matching #684's intent), while the A2ATaskTracker stays authoritative only for the context graph (resume) and the cancel agent-URL lookup.

Changes

  • a2aJob exposes its live polling state via the new optional domain.A2AStateProvider, and Supervisor.A2APollingStates() enumerates running A2A jobs. Because the job holds the same *TaskPollingState the poll loop mutates, this preserves the full A2A detail (context/agent id, last known state) with no A2A-specific fields added to the generic JobMeta/TrackedJob.
  • BackgroundTaskService.GetBackgroundTasks() and backgroundTaskRegistry.HasPending() now read the supervisor, so the /tasks rows, the /tasks summary count, and the status-bar indicator all derive from one source and can no longer disagree. The headless BackgroundTasksWaiter exit path is unaffected (it goes through HasPending).
  • Cancel is unified: CancelBackgroundTask now winds the supervised job (WindStop) so a cancelled task drops from the count/list at once instead of lingering until the poll independently observes the remote cancel. runA2APolling's ctx.Done() branch now carries result Data so the retained "Canceled" row survives the wind.
  • Closed a pre-existing data race on the shared TaskPollingState: A2APollingState composes the immutable identity fields with a mutex-guarded last-known state instead of copying the struct the poll goroutine mutates.

Interface-preserving: no counterfeiter mock regeneration required.

Testing

  • task build, task test (full suite), task lint (0 issues) — all green.
  • go test -race clean on internal/services, internal/services/jobs, internal/agent/tools (validates the race fix).
  • New tests: Supervisor.A2APollingStates (A2A-only, detail preserved, drops on finish); HasPending via the supervisor (a bare StartPolling no longer counts); GetBackgroundTasks sourced from the supervisor; CancelBackgroundTask winds the job; a concurrent A2APollingState race test; and TestA2ADivergenceGone — a regression guard proving the status-bar count and the /tasks list agree while running and drop together on finish.

Follow-ups (filed)

Discovered while fixing this; tracked separately:

no docs ticket: internal-only refactor

…visor (#693)

A2A tasks were dual-tracked: the submit path registered each task in both the
jobs.Supervisor (which the status-bar indicator counts via CountRunningJobs) and
the A2ATaskTracker polling set (which the /tasks active list and HasPending read
via GetAllPollingTasks). The two were cleaned up by independent paths and could
diverge, so a running A2A task could be missing from the status-bar indicator.

Make the supervisor the single source of truth for A2A liveness, matching #684's
intent, while the tracker stays authoritative for the context graph (resume) and
the cancel agent-URL lookup:

- a2aJob exposes its live polling state via the new domain.A2AStateProvider, and
  Supervisor.A2APollingStates enumerates running A2A jobs.
- BackgroundTaskService.GetBackgroundTasks and HasPending now read the supervisor,
  so the /tasks rows, the summary count, and the status-bar indicator share one
  source and can no longer disagree.
- CancelBackgroundTask winds the supervised job (WindStop) so a cancelled task
  drops from the count/list at once; runA2APolling's ctx.Done path now carries
  result Data so the retained Canceled row survives the wind.
- Close the pre-existing data race on the shared TaskPollingState: A2APollingState
  composes immutable fields with a mutex-guarded last-known state instead of
  copying the struct the poll goroutine mutates.
@edenreich
edenreich requested a review from a team as a code owner July 2, 2026 13:10
@edenreich
edenreich merged commit dcd0670 into main Jul 2, 2026
1 check passed
@edenreich
edenreich deleted the fix/a2a-status-bar-single-source-693 branch July 2, 2026 13:25
inference-gateway-releaser Bot added a commit that referenced this pull request Jul 3, 2026
## [0.128.0](v0.127.0...v0.128.0) (2026-07-03)

### 🚀 Features

* **chat:** make status indicators selectable with /tools and /a2a views ([#732](#732)) ([6882de0](6882de0)), closes [#717](#717) [#717](#717)

### 🐛 Bug Fixes

* **agent:** drop redundant Idle transition that errored on every run ([#726](#726)) ([469ec64](469ec64)), closes [#722](#722) [#725](#725)
* **agent:** report session-cumulative total_turns in completion logs ([#728](#728)) ([0d8fb08](0d8fb08)), closes [#727](#727)
* **a2a:** route active A2A reads and HasPending through the job supervisor ([#693](#693)) ([#721](#721)) ([dcd0670](dcd0670)), closes [#718](#718) [#719](#719) [#720](#720)
* **keybindings:** stop "unknown keybinding action" log flood ([#724](#724)) ([c828426](c828426)), closes [#714](#714) [#722](#722)
* **a2a:** unify background-job liveness, clear, and cancel on the supervisor contract ([#730](#730)) ([eb37fd0](eb37fd0)), closes [#693](#693) [#720](#720) [#718](#718) [#719](#719)
* **logging:** use structured key/value form at misused call sites ([#729](#729)) ([cd96028](cd96028)), closes [#722](#722) [#724](#724) [#724](#724) [#723](#723)
* **tools:** wait for pipe readers before reaping detached bash shells ([#716](#716)) ([e1d0d84](e1d0d84)), closes [#696](#696)

### ⚡ Performance Improvements

* **tui:** cache per-entry rendering and keep the Update loop responsive ([#731](#731)) ([8c9db0d](8c9db0d))

### 📚 Documentation

* **a2a:** add SKILL.md documentation for Agent2Agent protocol ([defcd57](defcd57))

### 🔧 Build System

* **deps:** bump golang.org/x/net from 0.47.0 to 0.55.0 in /examples/mcp/mcp-server ([#715](#715)) ([990803b](990803b))

### 🧹 Maintenance

* **flox:** bump dev deps ([d0c8f6b](d0c8f6b))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.128.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] A2A active tasks missing from the background-jobs status-bar indicator

1 participant