Related:
Worker runtime switches execution mode based on AGENT_ROLE:
worker: implementation changestester: test-centric changesdocser: documentation changes
This page describes shared behavior of the Worker runtime.
For Tester/Docser-specific differences, see:
Out of scope:
- Overall backlog replan decisions
- PR approve/rework decisions
- Acquire runtime lock
- Checkout / branch prep
- LLM execution (
opencode,claude_code, orcodex) - Expected-file verification
- Run verification phase
- Commit/push + PR creation (github mode) or local diff (local-git mode)
- Update run/task/artifact
- Release lease and return agent to idle
- Acquire runtime lock
- Snapshot pre-execution filesystem state (mtime + size)
- LLM execution (writes directly to
LOCAL_REPO_PATH) - Snapshot post-execution filesystem state
- Compute diff (changed/added/removed files via snapshot comparison)
- Run verification commands (spawn-safe,
&&chains expanded) - Create
direct_editartifact with change summary - Task transitions directly to
done(no judge review) - Release lease and return agent to idle
Research flow (task.kind=research):
- Acquire runtime lock
- Build research input from
task.context.research - Load claim/evidence snapshot
- Run research prompt execution (non-git path)
- Persist claims/evidence/report artifacts
- Update run/task state (
doneorblocked(awaiting_judge)for write stage when judge required) - Release lease/runtime lock
The verification phase includes multiple recovery steps, not just simple command execution.
- Execute explicit commands
- Retry on no-change failure
- No-op detection (pass assumed when verification passes)
- Deterministic policy violation recovery
- Optional LLM policy recovery (
allow|discard|deny) - Discard + learn generated artifacts
- Verification recovery (retry around failed commands)
When unresolvable:
- policy/verification failure ->
blocked(needs_rework)
Success:
github/local-gitmode with review required ->blocked(awaiting_judge)directmode ->done(always, no judge review)- No review required ->
done
Failure:
- Quota-related ->
blocked(quota_wait) - Verification/policy ->
blocked(needs_rework) - Other ->
failed
Research-specific notes:
plan/collect/challenge/writestages run without checkout/branch/commit/pr- Search is model-tool-driven; no dedicated external search provider integration is required
- Pre-check for denied commands
- Commands containing shell operators are excluded from execution
- Runtime lock + queue guard prevent duplicate execution
- Expected-file mismatch reflected as warning/failure
Commands are executed via spawn, not shell. The following are not supported:
$()|,||,;,<,>,`
Notes:
&&is supported only as a verification-chain splitter.cd <path> && <command>is handled as cwd transition plus command execution.- Shell builtins such as
source/exportare not directly executable and are treated as verification format/setup failure.
- Startup entrypoint and role resolution:
apps/worker/src/start.ts,apps/worker/src/main.ts - Execution body:
apps/worker/src/worker-runner.ts(github/local-git),apps/worker/src/worker-runner-direct.ts(direct) - Verification phase:
apps/worker/src/worker-runner-verification.ts - Role-specific helper behavior:
apps/worker/src/worker-task-helpers.ts - Runtime lock:
apps/worker/src/worker-runtime-lock.ts - Verification command handling:
apps/worker/src/steps/verify/ - Research runner:
apps/worker/src/research/runner.ts - Research prompt/persistence:
apps/worker/src/research/prompt.ts,apps/worker/src/research/persist.ts
AGENT_ID,AGENT_ROLEWORKER_MODEL,TESTER_MODEL,DOCSER_MODELREPO_MODE,REPO_URL,BASE_BRANCHLOCAL_REPO_PATH,LOCAL_WORKTREE_ROOTWORKER_AUTO_VERIFY_MODEWORKER_VERIFY_CONTRACT_PATHWORKER_NO_CHANGE_RECOVERY_ATTEMPTSWORKER_VERIFY_RECOVERY_ATTEMPTSWORKER_VERIFY_RECOVERY_ALLOW_EXPLICITWORKER_VERIFY_SKIP_MISSING_EXPLICIT_SCRIPTWORKER_VERIFY_SKIP_INVALID_AUTO_COMMANDWORKER_VERIFY_AUTO_NON_BLOCKING_AFTER_EXPLICIT_PASSWORKER_VERIFY_INLINE_COMMAND_RECOVERYWORKER_VERIFY_INLINE_COMMAND_RECOVERY_CANDIDATESWORKER_POLICY_RECOVERY_USE_LLMWORKER_POLICY_RECOVERY_ATTEMPTSWORKER_POLICY_RECOVERY_TIMEOUT_SECONDS