Repository navigation
feat(platform): show a task's labels to agents in task_find and task_get - #5004
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
An agent now reads a task's labels one way, wherever it meets the task:
task_findrow and the tasktask_getreturns carrylabels. 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[].Labels: …) names the same labels in the same order, read the same way. It says nothing about labels when the task has none.task_getview: "occupancy"leaves labels out, and its description says so.task_findandtask_gettool descriptions name the new field.backend/domains/tasks/spec.md, and covers the brief too. A row intests/manual/reference/automation/tasks.mdrecords what the automated tests cover.platform/projects/task-automation, plus a paragraph indevelop/api-reference. That paragraph sits after thestage_fileparagraph, 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-humanandblocked, and triage reads them. But the agent task tools returned no labels:compactTaskinworkspace_domain_tools.tshad 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 againstapp.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'slistTasksForAgenthandler reads the page's labels alongside its captured reviews (Promise.all) and addslabelsto each row.task_get: the chat shim'sgetTaskContextForAgentnow selectslabel_idsand addslabelsto the task. The chat assistant'srag_fetchreads the same context but picks its own fields, so its output is unchanged.readTaskBrief(task-brief-read.ts) now takes its names fromreadAgentTaskLabelsand no longer has a query of its own. This serves both engines (the native turn, and the sandbox host viagetTaskBriefForAgentRun).compactTaskpasseslabelson when the read supplied them. If a row has nolabelsfield, the field is left out rather than shown as "none".Doors
POST /api/tools/execute): the only door that servestask_find/task_get. Changed.task_find/task_getare not MCP tools.tools.schema.snapshot.json, the MCP and OpenAPI contract fingerprints, the skill snapshot andAPI_CONTRACT_VERSIONare unchanged. No/api/v1or MCP surface changes. The field is additive and has no contract version, matching feat(platform): let project agents page the queue and read run state #3963 and fix(platform): expose validated workflow run identity #4902. The API reference says so, and tells a client to read a missinglabelsas unknown.Upgrade facts
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.GET /api/v1/projects/{id}/tasks/{taskId}still returnslabelsin the order stored on the task. Only the agent reads sort them.How tested
serverproject), 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 whatreadAgentTaskLabelsanswers (sorted, own project, org-scoped read), and the composed brief readsLabels: hold, Needs-human. A task with no labels, or with only another project's, gets nolabelsand noLabels: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.[TASK-R83], andtests/guards/domain-specs.guard.test.tspasses.tsc --noEmitpasses.oxlint --type-awarepasses on every changed file.oxfmt --check,lint:manualandlint:linkspass. The docs workspace's locale and prose tests also pass:locale-outline,locale-translation,locale-components,structure-proseanddocs.checkAgentTaskReadTools(agent-read-tools.integration.ts) stores labels out of order with one from another project.task_findandtask_getmust 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 inintegration-check.ts). It mints a token for the dispatch's run on Billing and lists both boards' To do tasks throughPOST /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 thattask_geton the Billing task agrees. Its session row and token are deleted right after the case.Before merge
[TASK-R83]records are green: two incheckAgentTaskReadTools, one incheckDispatchAcrossProjects. 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
rag_fetchon atask:ref still shows no labels. It is a different tool, outside this unit.task.get/task.liststill answer without labels. They are workflow steps, not agent task tools.