Skip to content

feat(platform): run standard agent tasks on the shared chat engine - #4844

Merged
yannickmonney merged 10 commits into
mainfrom
feat/tasks-on-the-shared-agent-engine
Oct 12, 2026
Merged

yannickmonney merged 10 commits into
mainfrom
feat/tasks-on-the-shared-agent-engine

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What

A person who starts the managed standard agent on a task now gets the chat's engine, not a separate one. The same turn loop (executeTurn → runTurn), the same tool table and executors, the same ladder (none → light → full), the same skills, files, budgets and usage ledger. A task that needs a full workspace hands over to the agent's own worker, with a brief.

Chat reply Task run on the standard agent
Engine executeTurn for the person, on their thread executeTurn for the person who started the run, on a bare task_run transcript thread
Tools chat tools + work tools (create_file, generate_image, load_skill, read_skill_file, run_code) the same executors, plus use_workspace (tier full)
Skills the person's catalog the agent's equipped skills, read with the project's viewer
Files thread-bound file rows, cards under the reply bound to the run's transcript until the run delivers them; a deliverable then belongs to the task alone
Light sandbox one per conversation, released after 5 idle minutes one per run, released when the run ends; a background run waits up to about 90 s for room
Budget and usage assertChatTurnBudget + hold the same, for the starter, under the agent and the project
Stop cancel_requested on the reply's generation the same flag, on the run transcript's generation; the turn also asks its run every few seconds, so a Stop that lost its flag still lands
Full tier none (hand over to a task) use_workspace moves the run to the harness with the pass's reason and brief
Concurrency one turn per thread at most four native runs per organization at once; the next waits queued

Which runs are native. Only a run a person starts (a user, an API key, an @mention or the description), on the managed standard agent, on an automatic runtime. Schedules, automations and other agents, agents with connectors, platform tools or secrets, a pinned runtime, a model only a runtime can serve (a subscription's), and every project agent a person created keep running in a worker, as before. The decision is StandardAgentServing.engine, taken once in kickAgentRun and stored on the run.

Hand-over. use_workspace records the request; the host files what the pass made as task deliverables, flips the run to the harness under a fresh exec, stores the brief (handoff) and queues the harness start. A retry of such a run goes straight to the harness with the same brief, so a native start never repeats the work.

Lifecycle. Launch, attach the transcript, admit the budget, run the turn, settle through the same completeAgentRunInTx a harness run uses (report comment, delivery notice, deliverables, in_review). Failures keep their classes and retry posture: model_capacity (429) arms the automatic retry, budget_exceeded, deadline and the new policy_refused (the org's content policy) do not, turn_crashed comes from the watchdog or a worker shutdown. A comment that @mentions a running native run stops it and starts the next in one savepoint. Recovery uses its own queue (task.agent_native); the stalled-turn sweep never touches a native run.

Data

Migration 0202_agent_run_engine.sql: project_agent_runs.engine ('native' | 'harness', NOT NULL DEFAULT 'harness', so an older image's insert is a harness run during a rolling deploy), thread_id (FK, ON DELETE SET NULL), handoff jsonb, and a partial index for the watchdog's question. No backfill.

Shared code

  • domains/chat/{artifacts,image-billing} moved to domains/agent_tools/; new image-model.ts (the one place a host resolves the image model) and turnWorkToolsFor in the executor.
  • executeTurn gained three seams, none used by chat: persona, personalContext, signal.
  • Settle comments (core/tasks/settle_comments.ts), the task brief read (task-brief-read.ts), the agent's skill scope (agent-skill-scope.ts), the output staging cap and the per-run file cap (lib/shared/run-output-cap.ts) are read by both the harness and the native host.
  • lib/agent/{task-persona,transcript}.ts: the task persona is the chat's pieces (NO_FABRICATION, NO_RAW_CONTEXT, the ladder) plus the task framing; the run card reads the transcript in the wire a harness log has.
  • tasks/run-transcripts.ts: the one end of a run's transcript, taken by a task's deletion, the agent-run retention window and a person's erasure.

Review

Two independent review agents (security and permissions; lifecycle and concurrency) read the diff adversarially, and two native-language reviews read the German and French docs. Every confirmed finding is fixed in the last two commits, each with a test or a real-Postgres proof:

  • A native run counted as holding a worker in the claim, the idle release, the orphan sweep, the workspace cleanup, the wake order and the slot-release signal; a harness run beside it opened a second worker and the first never stopped. Harness runs only now (TASK-R37; the lane proof fails without the filter).
  • A task deleted under a working run took the Stop flag with the transcript, and the turn kept working; the turn now asks its run every 15 s and stops at its next step (TASK-R35). The same write keeps updated_at_ms moving, which also covers an older image's stalled-start sweep during a rolling deploy, and the end of the turn stamps the run before its generation row goes, so the watchdog cannot fail a run in the settle window.
  • A deadline or a shutdown abort was classified as a provider failure and retried; it is now read from the signals (deadline for good, turn_crashed for a shutdown).
  • Transcripts outlived the run record and a person's erasure, and erasure took the bytes of a deliverable the task listed. A deliverable now lets go of the transcript and the starter when it is claimed; the transcript goes with the record at the retention window and with its starter's erasure (TASK-R36).
  • No per-organization limit: four native runs per organization at once through the queue's group limit, with a heartbeat so a killed worker's run stops counting within two minutes; a queued run is not re-kicked (TASK-R38).
  • No output caps: 64 files per run, the rest named as not delivered; the brief lists the newest deliverables.
  • A starter who left the organization is refused; an unreadable skill library no longer fails a run for good; the hand-over takes the task row before it records outputs; eight watchdog tests this branch had dropped are back.

Known limits, as for a run in the full workspace: the run acts with its starter's reach and reads task text any project reader can write, and its tool outputs show on the run card; the tool outputs of external sources are wrapped as untrusted content, and run_code has the light sandbox's profile. The chat_tools policy governs the chat assistant only. A run whose starter is removed mid-run ends with its turn, as a run in a worker does.

Data, UI, docs, i18n

  • Sandboxes: the light sandbox caption is Light sandbox (it serves chat and tasks); Governance > Models says what the standard agent runs on for the person looking (works with … and hands over to …).
  • The run card reads a native run's transcript; policy refusals have their own failure copy and notification.
  • Docs EN/DE/FR: new "How a standard agent run works" section (#standard-agent-runs), plus sandboxes, content models, task automation, tasks, chat files, erasure and the standard agent policy reference; the governance-standard-agent screenshot is recaptured through the pipeline (its readiness gate accepts either wording of the line).
  • EN/DE/FR message keys; manual boxes TASK-F86–F91 and TASK-B53, GOV-F50; automation row; spec rules TASK-R30–R38 with tests naming them.

Verification

  • Platform server + pii suites 88,064 tests and UI suite 7,648 pass on the final tree (one load-timing test, travels.test.ts, failed once on a loaded machine and passes alone, three runs; it fails on main the same way), docs structural suite 713, guards 277.
  • New real-Postgres lane checkNativeAgentRuns (scripted engine seam, jobs held inert): the column shape, routing, settle, the transcript wire, file access and deliverable ownership, hand-over and its retry, rate limit, content policy, retire, Stop, the sweeps, the wake of a stranded queued run, and worker occupancy; plus the retention sweep and the erasure lanes with a native run's transcript.
  • Driven in the browser on a local stack with the mock gateway and a real spawner: a run that makes files with create_file and run_code settles with deliverables, comments and a readable transcript; use_workspace hands over and the retry carries the brief; Cancel run on a working run ends it as cancelled and its light sandbox is destroyed; an @mention on a working run cancels it and starts the next with the comment as its feedback, which then settles.
  • tsc --noEmit, type-aware oxlint, oxfmt, knip, lint:manual, lint:links.

Not in this PR

  • Native runs for agents other than the standard agent, the MCP bridge on the shared executors, and the full tier in chat itself.

…ace tool

The brief a task run is told — title, project, labels, description,
discussion, feedback, who started it, and now what a lighter pass handed
over — is composed in one place (lib/agent/task-brief.ts) and the
workspace host's prompts are rebuilt on it, byte for byte (72 prompt cases
compared before and after). The work tools gain use_workspace, the full
tier's tool: a turn hands its work to the full workspace with a reason and
a brief, when the lane gives it somewhere to hand it to. A turn can also
be narrowed to the skills its agent is equipped with.
Move artifacts and image billing out of the chat domain into agent_tools,
and add the one image-model resolver and turnWorkToolsFor beside them, so a
task run assembles the same work tools a chat reply does.

executeTurn gains the persona, personal-context and signal seams a task run
needs; chat passes none of them and reads the same prompt as before. run_code
can wait for a light sandbox when its caller has nobody to ask again, and a
light sandbox can be released when its owner is done with it.

The settle comments of an agent run move to core/tasks so the harness and the
next engine post one body.
A task a person starts on the managed standard agent now runs on the chat's
engine: the same turn loop, tool executors, tiers (none, light, full), skills,
files, budget and usage ledger. Its transcript is a bare task_run thread, its
files become the task's deliverables, and its light sandbox is released when
the run ends. A run that needs a full workspace hands over to the harness with
a brief, and a retry of it goes straight there.

project_agent_runs gains engine (default harness, so an older image's insert
stays a harness run), thread_id and handoff. Native runs have their own job
queue and recovery, and the watchdog fails one whose turn is gone.
Schedules, automations, other agents, agents with connectors, tools or
secrets, a pinned runtime and subscription-only models keep running in a
worker.

An organization's content policy refusing a run is its own failure class: no
retry, and the starter is told in the policy's words. Files a run made read
for the people who can read the task's project.

The light sandbox caption becomes "Light sandbox" in all locales, Governance >
Models says what the standard agent runs on for the person looking, and the
run card reads a native run's transcript. Spec rules TASK-R30 to TASK-R35 with
tests naming them, a real-Postgres lane, and manual boxes TASK-F86 to F90 and
TASK-B53 ship with it.
Add "How a standard agent run works" to the project agents page, and update
the sandboxes, content models, task automation, tasks and chat files pages
to say what a person-started standard agent run does: works without a
worker, makes files in a light sandbox, and hands over to its full workspace
when the task needs one. English, German and French.
The line under the Standard agent section now says the agent works with the
chat's tools and hands over to a runtime when a task needs a full workspace,
so the shot shows it and the capture waits for either wording. Alt text in
English, German and French follows.
GOV-F50 named only the "runs on" line; with the runtime on Automatic the
section now says the agent works with the model and hands over to the runtime.
Leaving harness out lets a run a person starts work with the chat's tools and
hand over to the default runtime only when a task needs a full workspace;
setting it runs every task in that runtime. English, German and French.
Findings of an independent review of the native task runs.

A native run holds no worker, so the queries that read which runs occupy an
agent's workers (the claim, the idle release, the orphan sweep, the workspace
cleanup, the wake order) now count harness runs only, and its end frees no
slot. Before, a working native run made a harness run of the same agent open
a second worker and kept the first from stopping.

Its turn is tied to its run: it proves the run alive while it works and
stops at its next step once the run is no longer live, so a task deleted
under it no longer leaves it working on a transcript that is gone. A run past
its time limit fails for good, and a worker shutdown fails it as interrupted,
whichever shape the engine reports the abort in. The turn's end stamps the
run before the generation row goes, so the watchdog's grace for the settle is
measured from there.

An organization works at most four native runs at once through the queue's
group limit, with a heartbeat that lets a killed worker's run stop counting
within two minutes; a run waiting its turn is not re-kicked.

A deliverable belongs to its task from the moment it is claimed: it lets go
of the run's transcript and of the person who started the run. A transcript
ends with its run's record at the retention window and with its starter's
erasure; the files only it held are released with it.

A run delivers at most 64 files and its brief lists the newest deliverables,
as a harness run's does. A starter who has left the organization is refused,
an unreadable skill library no longer fails a run for good, and the
hand-over takes the task row before it records the deliverables.

Spec rules TASK-R36 to TASK-R38 with tests naming them, real-Postgres proofs
for the worker occupancy, the retention sweep and the erasure, and the
restored watchdog tests this branch had dropped.
Say that an organization works four such runs at once, that a run stops after
about 50 minutes, and that an erasure takes the transcripts of the runs a
person started while the deliverables stay. German and French wording follows
a native-language review: the meaning of "nobody to ask again", the pronouns
that read as the wrong subject, the sentences that were too long, and the
catalog name for a task's deliverable files.
The receipt of an erasure compares the chat threads a request targeted with
the threads it erased. Counting a native run's transcript among the chats made
the receipt read two erased for one targeted, so the transcripts have a pass
and a label of their own, in every locale.
@yannickmonney
yannickmonney added this pull request to the merge queue Oct 12, 2026
@yannickmonney

Copy link
Copy Markdown
Contributor Author

Queued at head 469068c100 (PR-tier checks green). Before enqueueing, two independent review agents (security and permissions; lifecycle and concurrency) read the diff adversarially and two native-language reviews read the German and French docs. Every confirmed finding is fixed in 0de2e440c3 and 469068c100 and listed under Review in the description, each with a test or a real-Postgres proof. Full local backend integration on this head: 2069/2072, the three failures being the video-link whisper/yt-dlp checks that need tools this machine lacks. A rig check of the Stop-after-delete finding on the final code: the task was deleted while a native run worked, no further model call followed, the run's light sandbox was destroyed 7 s later, and no file landed.

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