Skip to content

feat(platform): show a task's labels to agents in task_find and task_get - #5004

Merged
yannickmonney merged 5 commits into
mainfrom
feat/agent-task-labels
Oct 15, 2026
Merged

yannickmonney merged 5 commits into
mainfrom
feat/agent-task-labels

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What

An agent now reads a task's labels one way, wherever it meets the task:

  • every task_find row and the task task_get returns carry labels. These are the task's label names, spelled as the project's catalog spells them and sorted without regard to case. A task without labels reads [].
  • the brief both engines open a task run with (Labels: …) names the same labels in the same order, read the same way. It says nothing about labels when the task has none.
  • the compact task_get view: "occupancy" leaves labels out, and its description says so.
  • the task_find and task_get tool descriptions name the new field.
  • spec rule TASK-R83 ("An agent sees a task's labels wherever it lists or reads the task") sits under "What a run is handed" in backend/domains/tasks/spec.md, and covers the brief too. A row in tests/manual/reference/automation/tasks.md records what the automated tests cover.
  • docs EN/DE/FR: the manager section of platform/projects/task-automation, plus a paragraph in develop/api-reference. That paragraph sits after the stage_file paragraph, outside the contract 3.12.0 sequence, and says the field comes with no contract version of its own.

Why

The fleet's agents are told to respect the labels hold, needs-human and blocked, and triage reads them. But the agent task tools returned no labels: compactTask in workspace_domain_tools.ts had no labels field, so an agent could not see them. The run brief did name labels, but in stored order, by id alone, with no check on organization or project. That meant one agent saw one task's labels in two ways.

How

  • readAgentTaskLabels (backend/domains/tasks/agent-labels.ts) runs one query per page against app.task_labels, scoped to the organization. A label counts only when the task's own project holds it, so an id from another project's catalog, or from a deleted label, names nothing. Names are deduplicated and sorted by case-folded code-unit order, so the result does not depend on the database's collation. Each task is matched against its own project, so a page that mixes the agent's board with a board its dispatch serves reads each board's labels.
  • task_find: the sandbox write shim's listTasksForAgent handler reads the page's labels alongside its captured reviews (Promise.all) and adds labels to each row.
  • task_get: the chat shim's getTaskContextForAgent now selects label_ids and adds labels to the task. The chat assistant's rag_fetch reads the same context but picks its own fields, so its output is unchanged.
  • Run brief: readTaskBrief (task-brief-read.ts) now takes its names from readAgentTaskLabels and no longer has a query of its own. This serves both engines (the native turn, and the sandbox host via getTaskBriefForAgentRun).
  • The bridge: compactTask passes labels on when the read supplied them. If a row has no labels field, the field is left out rather than shown as "none".

Doors

Upgrade facts

  • The agent tool answer only gains a field. No migration and no configuration change.
  • A run brief's Labels: line is now sorted without regard to case. It no longer names an id from another project's catalog or another organization: such an id could only get onto a task by a direct database write.
  • REST GET /api/v1/projects/{id}/tasks/{taskId} still returns labels in the order stored on the task. Only the agent reads sort them.

How tested

  • Unit tests (vitest, server project), all passing:
    • agent-labels.test.ts: catalog spelling, case-insensitive sort, one org-scoped read per page, a foreign or deleted id dropped, no query when no task has labels. One case reads a page of two projects, where each task also carries an id from the other project's labels: each task gets only its own project's names, from one read. It fails if a regression matches against a page-wide project.
    • task-brief-read.test.ts (new): the brief's labels match what readAgentTaskLabels answers (sorted, own project, org-scoped read), and the composed brief reads Labels: hold, Needs-human. A task with no labels, or with only another project's, gets no labels and no Labels: line. Both cases fail against the previous brief query.
    • workspace-write-shim.test.ts, chat/shim.test.ts, workspace_tools_bridge.task_reads.test.ts, native-turn.test.ts, lib/agent/task-brief.test.ts.
    • Each new test names [TASK-R83], and tests/guards/domain-specs.guard.test.ts passes.
  • Platform tsc --noEmit passes. oxlint --type-aware passes on every changed file.
  • oxfmt --check, lint:manual and lint:links pass. The docs workspace's locale and prose tests also pass: locale-outline, locale-translation, locale-components, structure-prose and docs.
  • Integration cases, written but NOT_RUN locally. They need a Postgres that the repo scripts do not start.
    • checkAgentTaskReadTools (agent-read-tools.integration.ts) stores labels out of order with one from another project. task_find and task_get must read them sorted and without the foreign label, and a task without labels reads []. A second record reads the same task's brief through the turn shim (getTaskBriefForAgentRun).
    • checkDispatchAcrossProjects (dispatch-across-projects.integration.ts) now takes the server's base URL (one call site changed in integration-check.ts). It mints a token for the dispatch's run on Billing and lists both boards' To do tasks through POST /api/tools/execute. Each task also carries an id from the other board's labels. The case checks that the Billing task and the Development task each name only their own board's labels, and that task_get on the Billing task agrees. Its session row and token are deleted right after the case.

Before merge

  • Run Backend integration and confirm that the three [TASK-R83] records are green: two in checkAgentTaskReadTools, one in checkDispatchAcrossProjects. CI skips that job on drafts, and the queue runs it, so undraft the PR or run the candidate dispatch first. Until then, the automation row's "real Postgres" claim has not been backed by a run.

Not done

  • The chat assistant's rag_fetch on a task: ref still shows no labels. It is a different tool, outside this unit.
  • The automation capabilities task.get / task.list still answer without labels. They are workflow steps, not agent task tools.
  • What a label means to an agent (hold, needs-human, blocked) stays in each team's agent instructions. The platform only reports the labels.

Every task_find row and the task task_get returns now carry `labels`:
the task's label names as its project spells them, sorted without regard
to case, [] for a task without labels. A team steers its agents with
labels (one that holds a task back, one that waits for a person), and
the agent task tools gave an agent no way to read them.

One read per page (`readAgentTaskLabels`, domains/tasks/agent-labels.ts),
scoped to the organization; an id the task's own project does not hold
names nothing. The occupancy view leaves labels out. The tool
descriptions say so, and TASK-R83 states the rule.
The manager section of the task automation guide and the API reference
now say that task_find rows and the task task_get returns carry
`labels`, sorted without regard to case, and that REST keeps answering
them in the task's own order. EN, DE and FR.
A page of task_find can hold the agent's own board and a board its
project's dispatch serves. Nothing held that each task there is matched
against its own project's labels rather than one page-wide project.

agent-labels.test.ts reads one page of two projects, each task also
wearing an id of the other's labels. checkDispatchAcrossProjects now
lists both boards through the workspace-tool door as the dispatch's run
on Billing and reads a Billing task with task_get: each task names only
its own project's labels. The lane takes the server's base URL for it.
The brief both engines open a task run with read its label names in the
order the task stores them, by id alone. task_find and task_get read them
sorted without regard to case, within the organization, and only from
the task's own project. One agent saw one task's labels two ways, and
only one door kept another project's ids out.

readTaskBrief now takes the names from readAgentTaskLabels. TASK-R83
says the brief names them the same way, and says nothing of labels for a
task without them. task-brief-read.test.ts holds it, and
checkAgentTaskReadTools reads the labelled task's brief through the turn
shim.
The labels paragraph of the API reference sat inside the contract 3.12.0
sequence and read as part of it. It now follows the stage_file paragraph
and says the field comes with no contract version of its own, so a
missing labels reads as unknown rather than as a task without labels.
The task automation guide adds that an agent started on a task is told
its labels the same way. EN, DE and FR.
@yannickmonney
yannickmonney marked this pull request as ready for review October 15, 2026 22:42
@yannickmonney
yannickmonney merged commit 6b579ec into main Oct 15, 2026
@yannickmonney
yannickmonney deleted the feat/agent-task-labels branch October 15, 2026 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant