Repository navigation
Closed
Description
Context
The report is free-form prose and ProPR never parses it for actions. Acting on a report is a separate agent step: a second ordinary isolated task run whose input is the report and whose only means of acting is the existing ProPR MCP tools (create tasks, TODOs, PR comments, …). All judgment about what to do lives in that second agent.
Autonomy is a single mechanism with three modes that only decides whether/when the acting step runs:
| Mode | After the report |
|---|---|
dry_run |
Stop. Run is completed. The acting step is never invoked. |
preview |
Run waits in awaiting_approval. A human reads the report and approves (→ acting) or rejects (→ rejected). |
auto |
Run moves straight to acting. |
The mode is snapshotted onto the run at trigger time (issue 3), so editing the definition never changes the autonomy of an in-flight run.
Requirements
- Extend
src/jobs/agentRuns/autonomy.ts(advanceAfterReport):dry_run→report_ready → completed.preview→report_ready → awaiting_approval+ Inbox notification to the owner ("Agent report ready for review") vianotificationService.createNotificationEvent(categorytask).auto→report_ready → actingthenenqueueAgentRunPhase(run, 'action'). If enqueueing fails →acting → failedwith the reason.
- REST (add to
agentDefinitionRoutes.ts):POST /api/agent-runs/:runId/approve→awaiting_approval → actingwithapprovedBy = user id, enqueue action. Optional body{ note }(≤ 2,000 chars) appended to the acting prompt as operator guidance.POST /api/agent-runs/:runId/reject→awaiting_approval → rejected.- Both 409 when the run is not awaiting approval.
- New
src/jobs/agentRuns/actionPrompt.ts→buildAgentActionPrompt({ definition, run, report, operatorNote }):- The report is fenced as data (
<agent-report>), with an explicit statement that it may contain recommendations, which the agent must evaluate, not blindly execute. - Instructs the agent to use only the
proprMCP tools to act, restricted to the definition's repositories; to use idempotency keys of the formagent-run-<runId>-<n>; to prefer creating TODOs/tasks over duplicates (checklist_tasks/list_todosfirst); never to merge, deploy or change settings (and those scopes are not granted anyway). - Final message: a short human-readable summary of what it did and why (stored as
action_summary), including links/ids returned by tools.
- The report is fenced as data (
- New
src/jobs/processAgentActionJob.ts(createAgentActionProcessor(deps)), registered insrc/worker.tsreplacing the stub:- Requires state
acting; otherwise no-op. - Task
agent-run-<runId>-action(type: 'agent-run', subtitle "Acting on report"). - Workspace per the definition's
repository_readcapability (sameprepareAgentWorkspace). - Always requests an action-phase MCP grant (issue 9); toolPolicy with MCP on (issue 8). Revoke in
finally. - Success →
acting → completedwithactionSummary; failure →acting → failed.
- Requires state
- Tests:
test/agentAutonomy.test.ts(all three modes, approve/reject state guards) andtest/processAgentActionJob.test.ts(fakes, grant revoked on failure).
Implementation Specification
- Approve uses the same compare-and-set transition, so double-clicking Approve enqueues once (deterministic job id
agent-run-<id>-actionalso dedupes). - The acting agent model is the definition's model (v1); a separate acting model is a possible later option.
- The acting step re-checks the cost gate (issue 11) because
autoacting after a scheduled report is also unattended spend.
Acceptance Criteria
-
dry_run: no action job is ever enqueued; run endscompletedwith the report. -
preview: run waits inawaiting_approvaland the owner gets an Inbox item; approve → action job enqueued once; reject →rejected, no action job. -
auto: action job enqueued immediately after the report. - The acting run receives the report text and an MCP server in its tool policy; the grant is revoked even when the agent fails.
-
action_summaryis shown on the run and the action task is visible in/tasks.
Created by ProPR AI Planner
Activity
propr-dev commentedon Oct 6, 2026
Suggested Implementation:
Implementation Approach
Autonomy is implemented as one function (
advanceAfterReport) plus two human transitions (approve/reject), all through the guarded state machine from issue 3. The acting step is a second instance of the same executor pattern as the report step — a normal task run with a different prompt and an MCP grant — so we literally "reuse the same machinery twice", as requested.We deliberately do not parse the report: the acting agent receives it verbatim, fenced as data, and decides with judgment which MCP tools to call. ProPR's guarantees come from the narrow MCP grant (repositories +
read/plan/executescopes, issue 9) and the MCP layer's idempotent receipts, not from a schema.File:
src/jobs/agentRuns/autonomy.tsWhy this file: The single place that maps autonomy mode to the next lifecycle step.
The approval note needs a nullable
operator_notetext column: add migrationpackages/core/src/db/migrations/20261006010000_add_agent_run_operator_note.js(alterTable('agent_runs', t => t.text('operator_note')), down drops it). It keeps the note auditable next toapproved_by.File:
src/jobs/agentRuns/actionPrompt.ts(new file)Why this file: The acting agent's instructions. All "what should be done" judgment is delegated here, in prose.
File:
src/jobs/processAgentActionJob.ts(new file)Why this file: Worker processor for the acting step — the same isolated-run composition as the report step, with an MCP grant always attached.
Add the helper to
packages/core/src/services/agents/agentRunStore.ts:File:
packages/api/routes/agentDefinitionRoutes.tsWhy this file: The human half of
previewmode.startActingViaCorelives in core (agentRunAutonomy.ts: movestartActingfromsrc/jobs/agentRuns/autonomy.tsintopackages/core/src/services/agents/agentRunAutonomy.tsso both the API and worker import it;src/jobs/agentRuns/autonomy.tsre-exports it). Register['post', '/api/agent-runs/:runId/approve', ...]and['post', '/api/agent-runs/:runId/reject', ...]inserver.ts, and replace the worker stub withprocessAgentActionJob.File:
test/agentAutonomy.test.ts(new file)Why this file: One assertion per mode plus the approval race.
propr-dev commentedon Oct 6, 2026
🤖 AI processing has started for this issue using claude agent with claude-opus-5-5 model.
I'll analyze the problem and work on a solution. This may take a few minutes.
Processing Details:
claudeclaude-opus-5-52809/claude-opus-5-5-agents-v1-10-17-separate--20261006-2137-pp12800-epic-agents-v1-y7tissue-2809-20261006-2137-claude-opus-5-5-pp1🔍 Track Task Execution