Skip to content

Fix Common AI's AI Model tab for tasks inside a task loop - #75518

Merged
kaxil merged 1 commit into
apache:mainfrom
astronomer:fix-ai-model-tab-task-loops
Oct 23, 2026
Merged

kaxil merged 1 commit into
apache:mainfrom
astronomer:fix-ai-model-tab-task-loops

Conversation

@kaxil

@kaxil kaxil commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #74334, which added the AI Model tab, and #74351, which taught the HITL review plugin to address one loop pass.

For an @task.agent or @task.llm task inside a task loop, the AI Model tab shows "No AI Model Info" with "Select a region and index for this task instance", even though the task pushed its model name and usage XComs. The tab reads them by task id and map index only. For a loop task the XCom route also needs the loop pass, so it rejects the read with a 400. The tab now sends the selected task instance's region_id and region_index on both reads.

No core change. The host already passes the resolved taskInstance, which carries the region, to every plugin (ReactPlugin.tsx), and the HITL review plugin has used it since #74351. The region helpers move into a side-effect-free region.ts that both plugin bundles import, so the two tabs share one rule instead of two copies.

Older hosts keep the old requests. A host that predates the taskInstance prop never passes the key, so the tab reads without a region, as before. On a newer host the tab shows its loading spinner until the task instance resolves, rather than sending a read without the region.

A slow read for the previous loop pass no longer wins. The host remounts a plugin when the path changes (ExternalView.tsx), but the loop pass is a search param, so switching passes keeps the panel mounted while the old read may still be in flight. Its result is now dropped.

The new tests render the plugin in happy-dom, added as a dev dependency (the core UI tests use the same library). They check the region on both reads, the reread on a pass switch, and the stale-read case. Each of those fails if the region is dropped at any layer between the plugin props and the request.

Before: loop task shows the 400

After: refine.judge pass shows model and usage


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

The AI Model tab read the task's model name and usage XComs by task id
and map index only. For a task inside a task loop the XCom route needs
the loop pass too, so it answered 400 "Select a region and index for
this task instance" and the tab showed no model info.

The tab now forwards the selected task instance's region_id and
region_index from the host, the same way the HITL review plugin does.
Hosts that predate the taskInstance prop keep the map-only reads. The
region helpers move to a side-effect-free module both plugins share.
@kaxil
kaxil requested review from pierrejeambrun and removed request for Lee-W, ashb and gopidesupavan October 23, 2026 19:11
@kaxil kaxil added the affected_version:3.4.0rc Can be used for bugs identified during 3.4.0 testing label Oct 23, 2026
@kaxil kaxil added this to the Airflow 3.4.0 milestone Oct 23, 2026
@kaxil
kaxil requested review from Lee-W and vatsrahul1001 October 23, 2026 19:17
@kaxil
kaxil merged commit e9a89e2 into apache:main Oct 23, 2026
68 checks passed
@kaxil
kaxil deleted the fix-ai-model-tab-task-loops branch October 23, 2026 19:58
@kaxil kaxil removed this from the Airflow 3.4.0 milestone Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

affected_version:3.4.0rc Can be used for bugs identified during 3.4.0 testing area:providers provider:common-ai

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants