Repository navigation
feat(platform): run standard agent tasks on the shared chat engine - #4844
Conversation
…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.
|
Queued at head |
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.executeTurnfor the person, on their threadexecuteTurnfor the person who started the run, on a baretask_runtranscript threadcreate_file,generate_image,load_skill,read_skill_file,run_code)use_workspace(tier full)assertChatTurnBudget+ holdcancel_requestedon the reply's generationuse_workspacemoves the run to the harness with the pass's reason and briefWhich 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 inkickAgentRunand stored on the run.Hand-over.
use_workspacerecords 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
completeAgentRunInTxa 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,deadlineand the newpolicy_refused(the org's content policy) do not,turn_crashedcomes 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 todomains/agent_tools/; newimage-model.ts(the one place a host resolves the image model) andturnWorkToolsForin the executor.executeTurngained three seams, none used by chat:persona,personalContext,signal.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:
TASK-R37; the lane proof fails without the filter).TASK-R35). The same write keepsupdated_at_msmoving, 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.deadlinefor good,turn_crashedfor a shutdown).TASK-R36).TASK-R38).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_codehas the light sandbox's profile. Thechat_toolspolicy 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
works with … and hands over to …).#standard-agent-runs), plus sandboxes, content models, task automation, tasks, chat files, erasure and the standard agent policy reference; thegovernance-standard-agentscreenshot is recaptured through the pipeline (its readiness gate accepts either wording of the line).Verification
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.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.create_fileandrun_codesettles with deliverables, comments and a readable transcript;use_workspacehands 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