Repository navigation
fix(platform): serve the automation run's workspace tools - #3126
Merged
Merged
Conversation
An automation agent on demo05 could not use a single one of its granted
workspace tools. `ask_human` threw `[ctx-shim] un-shimmed mutation call:
automations/human_asks:createAskForExec` (GlitchTip DEMO05TALEDEV-4) and
every task/knowledge tool refused with `no_access_context` — so a run
could neither file work nor escalate a question.
Both are the same unfinished lane. The 0.5 port left two placeholders in
`domains/sandbox/shim.ts`: the binding resolver answered `none` for a
`workflow_run` session "until the automations engine ports", and the ask
handler was "deliberately NOT in this map" for the same reason. The
engine started minting those sessions in v0.5.5/0.5.6; the placeholders
never came out.
Seven more handler names the reused bridge reaches were in no map at all,
so every write tool would have thrown the same way once the access gate
opened: listTasksForAgent, agentCreateTask, agentUpdateTaskStatus,
agentUpsertTaskByExternalRef, and document_create's storeRawContent /
upsertDocumentByExternalId / linkDocumentToFile.
- The binding resolver carries 0.4's `sessionBinding` whole: `${runId}:…`
splits back to the run; a run pinned to a project acts there, one
without acts org-wide across its automation's bindings, and writes are
attributed to `automation:<name>`. Bindings are read UNJOINED — an
empty set means unbounded, so a join that dropped a row would widen
authority rather than narrow it.
- The write lane (`sandbox/workspace-write-shim.ts`) and the document
chain (`documents/agent-write.ts`) reuse the service functions the
human and connector lanes already call; `document_create`'s blob →
upsert-by-external-id → link → RAG chain becomes one reusable pair
instead of a fourth divergent copy.
- The ask handler moves verbatim into `automations/ask-shim.ts`, a leaf
both maps spread, because the sandbox map may not import the
automations map (it is already spread the other way round).
- `agentUpdateTaskStatusTrusted` answers a refusal CODE, not prose: the
bridge branches on `AGENTS_CANNOT_COMPLETE` to tell an agent to park at
`in_review`. The connector native renders the codes back into sentences
for the operator reading a failed run.
WHY NOTHING CAUGHT IT: the dispatch route's probe used a `project_agent`
session and the ask lane's probe called the handler map directly. Each
half green, the real chain never run. `domains/sandbox/shim.test.ts` now
walks the bridge's own import graph and fails on any reachable
`internal.x.y.z` the map cannot answer, and the integration suite drives
a real `workflow_run` session through `POST /api/tools/execute` for both
bindings — ask, create, find, the refused `done`, an out-of-reach card,
the idempotent external-ref sync, and both document scopes.
Integration 277/277 on a throwaway Postgres + MinIO.
`agentUpdateTaskStatusTrusted` refused EVERY terminal status for every actor. 0.4 refused only `done`, so the port's compression of `status === 'done' && actorId !== 'workflow'` into `TERMINAL_STATUSES.has(status)` swallowed `cancelled` with it — and an automation deciding "this ticket is obsolete, close the card" is a different act from certifying finished work. - `cancelled` is restored, with the human writer's open-subtasks guard (which the blanket refusal had made unreachable — the bridge branches on `TASK_HAS_OPEN_SUBTASKS` and could never receive it) and its `completed_at_ms` stamp, so the two lanes agree on what a closed card looks like. - `done` stays refused for every actor. The shipped catalog entry has said since #2857 that completion is the human review gate's; 0.4's `workflow` exemption was the half that disagreed with its own contract. The node now offers only what it can honour. `done` leaves the action's enum in `configs/platform/system/connectors/task/connector.yml` and the native's zod input, so a literal `status: done` fails at AUTHORING with `CONNECTOR_INPUT_INVALID` — the deploy-time contract check compiles that schema — instead of failing every single time the run reaches the node. A templated status still resolves at dispatch, where Ajv now NAMES the values that would have worked: it says "must be equal to one of the allowed values" and then does not say which, which leaves the caller with the one question they actually have. Integration 277/277: cancelling over an open child is refused, the child then cancels, the parent follows and lands `cancelled` with a completion stamp, and `done` stays unavailable. The natives suite covers the contract-level `done` refusal, the allowed `cancelled`, and the operator sentence a refusal code renders as.
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.
Summary
An automation agent on demo05 could not use a single one of its granted workspace tools:
ask_humanthrew[ctx-shim] un-shimmed mutation call: automations/human_asks:createAskForExec(DEMO05TALEDEV-4) and every task/knowledge tool refused withno_access_context, so a run could neither file work nor escalate a question. Both are the same unfinished lane — the 0.5 port left theworkflow_runbinding resolver answeringnoneand the ask handler out of the sandbox map "until the automations engine ports", and the engine started minting those sessions in v0.5.5/0.5.6. Seven more handler names the reused bridge reaches were in no map at all, so every write tool would have thrown the same way once the access gate opened.What changed
domains/sandbox/shim.ts) carries 0.4'ssessionBindingwhole:${runId}:<suffix>splits back to the run; a run pinned to a project acts there, one without acts org-wide across its automation's bindings, and writes are attributed toautomation:<name>. Bindings are read unjoined — an empty set means unbounded, so a join that dropped a row would widen authority.sandbox/workspace-write-shim.ts,documents/agent-write.ts) answers the seven missing names by reusing the service functions the human and connector lanes already call.document_create's blob → upsert-by-external-id → link → RAG chain becomes one reusable pair instead of a fourth divergent copy.automations/ask-shim.ts, a leaf both maps spread — the sandbox map may not import the automations map, which is already spread the other way round.agentUpdateTaskStatusTrustedanswers a refusal CODE, not prose: the bridge branches onAGENTS_CANNOT_COMPLETEto tell an agent to park atin_review. The connector native renders the codes back into sentences for the operator reading a failed run.Why nothing caught it
The dispatch route's probe used a
project_agentsession; the ask lane's probe called the handler map directly. Each half green, the real chain never run. Two guards close that class:domains/sandbox/shim.test.tswalks the bridge's own import graph and fails on any reachableinternal.x.y.zthe map cannot answer. Mutation-checked: removing the ask spread turns it red and namescreateAskForExec.workflow_runsession throughPOST /api/tools/executefor both bindings.The completion gate, re-read against its own contract
Second commit.
agentUpdateTaskStatusTrustedrefused every terminal status for every actor; 0.4 refused onlydone. The port compressedstatus === 'done' && actorId !== 'workflow'intoTERMINAL_STATUSES.has(status)and swallowedcancelledwith it.cancelledis restored — abandoning a card is not certifying it, and the automation lane had always been allowed to do it. It comes back with the human writer's open-subtasks guard (which the blanket refusal had made unreachable: the bridge branches onTASK_HAS_OPEN_SUBTASKSand could never receive it) and itscompleted_at_msstamp, so both lanes agree on what a closed card looks like.donestays refused for every actor —configs/platform/system/connectors/task/connector.ymlhas said since feat(platform): rewrite the AI backend on a minimal YAML-config core #2857 that completion is the human review gate's. 0.4'sworkflowexemption was the half that disagreed with its own catalog, so this is not a behaviour change; it is the contract winning.doneleaves the action's enum in the catalog and in the native's zod input, so a literalstatus: donenow fails at authoring withCONNECTOR_INPUT_INVALID(the deploy-time contract check compiles that schema) instead of failing every single time the run reaches the node. A templated status still resolves at dispatch, where Ajv now names the values that would have worked — it says "must be equal to one of the allowed values" and then does not say which.The agent-facing
task_update_statustool keepsdonein its vocabulary on purpose: a model learns from the structured refusal and its "park at in_review" guidance, whereas a human authoring a node should never be offered an option that cannot work.Checklist
bun run checkpasses (format, lint, typecheck, all tests) — 40/40 tasks.bun run lint:sastpasses (Opengrep) — 0 findings.messages/key added).backend/MIGRATION.mdsandbox row, which asserted the old placeholders, is updated in this change.Test plan
Observed 277/277 integration checks, including the new
automation-run tool lane (workflow_run session through /api/tools/execute)— which now also covers cancelling over an open child (refused), the child cancelling, the parent following with a completion stamp, anddonestaying unavailable. On demo05 after deploy: an automation agent'sask_humanshould register the question against its run instead of 500-ing, andtask_createshould land a card on the run's project board.