Repository navigation
[Epic] Let Claude goal runs ask the operator a question - #3460
Conversation
…h a question, the question shows under "Needs you" as a goal blocker, and the operator's next goal input comes back to Claude as the tool's answer. Typecheck passes for shared, core, api, cli and root. The changed and new tests pass, and eslint `--max-warnings 0` is clean for the touched files. How it works - The tool (`operatorQuestionMcpServer.ts`): a small inline stdio MCP server like the repository scout. It takes one question (up to 1000 characters) with optional 2–10 options of up to 200 characters, the same limits as `goalBlockers.ts`. The description tells Claude to ask only about decisions it can't settle from the goal, the repository or a sensible default, and never to ask for credentials. The same guidance goes into the context turn of a fresh session. - Transport: each attempt gets its own exchange directory under `/tmp/claude-logs/propr-operator/<uuid>/`, which the container already mounts. The server writes a request file and waits for a response file. Nothing needs the ProPR API or network access, so it works in restricted network mode, and no credentials are added. Claude runs as `node` inside the container, so the request directory is writable by others but can't be listed, and the directory names are random. - Wait limit: I checked the installed Claude CLI binary for how MCP tool calls time out. `MCP_TIMEOUT` only covers startup. Tool calls have a per-server `timeout` that is a hard limit (progress notifications don't extend it), plus a 30-minute idle limit for stdio servers that rises to match it. The config therefore sets that `timeout` above the maximum wait. - Worker side (`claudeOperatorQuestions.ts`): this follows the Codex behaviour. - Each question is recorded as a `question` blocker with `send_input` among its actions, fenced to the run generation, claim and session. - The first input after the question appeared becomes the tool result. It is marked delivered and the blocker is resolved. - Input that was already queued, or input sent while several questions wait, is delivered as an ordinary correction, as today. - Lifecycle: - The goal keeps heartbeating while Claude waits. The turn never ends, so the continue nudge never fires. - Pause or cancel closes the question first and then interrupts. - When a turn or attempt ends, open questions are closed (`turn_ended` / `attempt_ended`) and the tool call fails cleanly. A replaced attempt is closed by the existing `superseded_by_attempt` path. - The exchange directory is removed when the attempt finishes. - Timeout: a new instance setting, `goal_question_max_wait_ms`, defaults to 24 hours, has a 60-second minimum, and is capped by the agent timeout. When it runs out, Claude gets a clear "no answer" message. The server has its own deadline in case the worker is gone. The setting can be changed through the REST API, `update_execution_settings` and `propr setting update`, and is listed in the settings catalog. - Goal mode only: `buildDockerArgs` adds the tool only when `executionMode === 'goal'`. A test checks that task-mode arguments are identical with or without the option. - Capabilities and docs: - `GOAL_BLOCKER_PROVIDER_SUPPORT` now lists Claude questions as `supported`; approvals stay unavailable. - `get_goal_capabilities` has a new `controls.operatorQuestions` field, true for Codex and Claude. - I updated `goals.md` (new "Claude questions" section and the provider table), `mcp.md`, `propr-cli.md` and the CHANGELOG, and regenerated `settings-locations.md`. Things to know - Two new blocker resolution values, `answered` and `question_timed_out`, are stored for audit. - Every agent container mounts `/tmp/claude-logs` read-write. Another container could therefore, in principle, write into a goal's exchange directory if it knew the random name. - Nothing has been run against a live Claude container. The tests run the real inline server as a process, and the goal protocol is tested with a scripted session. - No visual preview: the UI didn't change. Tests - New `test/claudeOperatorQuestions.test.ts` covers: the round trip through the real server, fencing, input boundaries, several waiting questions, input checks, declining questions during the context turn, timeouts on both sides, attempt end, directory permissions, launch arguments and the capability projection. - `test/claudeNativeGoal.test.ts` gains protocol tests: the answer arrives as the tool result and not as a message, earlier input stays a correction, pause and cancel while waiting, and the context-turn guidance. - I updated the existing assertions in `goalBlockers`, `goalExecutionMode` and `configRoutes.followup`, and added a validation test for the setting in the CLI.
…es/api/test/mcpObservableSurface.test.ts`. I fixed the Shard 2/4 failure. The failing test was `packages/api/test/mcpObservableSurface.test.ts`. **Cause:** that test checks every snake_case name in `docs/mcp.md`. Each one must be either a ProPR MCP tool an admin can see, or a word on the test's list of non-tool names. This PR's doc changes added two names that are neither: - `ask_operator`: the tool injected into Claude goal sessions, not a ProPR MCP tool. - `goal_question_max_wait_ms`: the new instance setting. **Fix:** I added both names to the non-tool list in the test, with a comment saying what they are. The docs themselves are unchanged. **Checks:** - The failing test passes locally (it failed twice first, once for each name). - ESLint with `--max-warnings 0` is clean for the file. - 20 related suites pass, covering the docs, settings catalog, OpenAPI coverage, Claude agent launch and goal tests. Shards 1, 3 and 4 of that CI run were cancelled when shard 2 failed, so they never finished. The 20 related suites pass, but the rest of what those shards cover hasn't been run on this commit. That happens on the next CI run. PR: #3452 Comment by: @propr-dev[bot] (ID: 6808837238) Model: Claude Opus 5.5
…attempt's own timeout, so Claude always gets the no-answer result while it can still act on it. Before, a question asked partway through an attempt could still be waiting when the attempt was killed. I fixed F1. A Claude question now stops waiting before the attempt's own timeout, so Claude always gets the no-answer result while it can still act on it. Before, a question asked partway through an attempt could still be waiting when the attempt was killed. **What changed** - **One shared close time.** Before building the container, `executeClaudeNativeGoal` works out when the attempt started plus the agent timeout, minus a reserve of 5 minutes (or a tenth of the timeout, if that is shorter). Questions close at that time. The kill timer starts slightly later, so this close time is always before the kill. The new `boundOperatorQuestionLaunch` helper in `operatorQuestionMcpServer.ts` computes it, and `buildDockerArgs` now receives this bounded launch from the attempt. - **Worker side (`claudeOperatorQuestions.ts`).** - Each question's expiry is now the earlier of "opened + maximum wait" and the attempt's close time. - When the close time is what ends the wait, Claude gets "No answer from the operator before this goal attempt runs out of time…", and the blocker is still resolved as `question_timed_out`. - With less than 60 seconds left before the close time, a new question gets the no-answer result immediately and no blocker is shown under "Needs you". - **Server side (the fallback if the worker is gone).** The close time is passed in as `PROPR_OPERATOR_CLOSE_AT`. The server checks it before writing a request, so it turns down a late question by itself. It also never waits past the close time plus its 30-second grace. It now passes on the worker's no-answer message instead of always printing its own. - **Tool description.** The "at most …" wait it gives Claude is capped by the time left in the attempt at launch, so it is accurate. - **Docs.** I updated the "No answer" bullet in `docs/docs/features/goals.md` and the CHANGELOG entry. **New tests** in `test/claudeOperatorQuestions.test.ts`: - The scenario from the finding: a one-hour attempt with the default 24-hour setting. A question opened at minute 10 is still waiting just before minute 55 and gets the no-answer result at minute 55, before the kill at minute 60. - A question asked with under a minute left gets the immediate result and no blocker. - The server alone turns down a question when its close time is near, without writing a request file. - The bounded launch values, including the tenth-of-timeout reserve for short timeouts, reach the server's environment. **Verification:** - `claudeOperatorQuestions` passes 21 of 21. `claudeNativeGoal` passes, and so does `nativeGoalLaunchBoundary`, which needs `--experimental-test-module-mocks` on this container's Node 22. - `tsc` passes for `packages/core` and the root project. - eslint with `--max-warnings 0` is clean on the four changed core source files. The test file is outside the root eslint config, as it was before. - Nothing has been run against a live Claude container. The UI didn't change, so there is no visual preview. PR: #3452 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5
…tor` call while the goal turn is still running, the "Needs you" blocker now closes. The operator's next input is then delivered to Claude as an ordinary message, instead of being marked delivered as an answer nobody reads. F2 is fixed. When Claude's MCP client cancels an `ask_operator` call while the goal turn is still running, the "Needs you" blocker now closes. The operator's next input is then delivered to Claude as an ordinary message, instead of being marked delivered as an answer nobody reads. **How it works** - **Shared claim file:** each question now has a `<request id>.claim` file in the exchange's `requests/` directory. It can only be created once (exclusive create). Whichever side creates it first, the worker delivering an answer or the server handling a cancellation, decides what happens to the input. - **Server** (`operatorQuestionMcpServer.ts`): - When `notifications/cancelled` arrives, the line handler writes the claim as `cancelled` right away, without waiting for the poll loop. - The wait is now registered before the request file is written. A cancellation that arrives during that write is no longer lost, and the claim exists before the worker ever sees the request. - **Worker** (`claudeOperatorQuestions.ts`): - `sync` skips a new request that is already cancelled, so it never becomes a blocker. It also closes any open question whose claim exists, with resolution `provider_resolved` (the value Codex uses when the provider withdraws a request). - `answer` does the same cleanup before choosing a question, so one cancelled question no longer blocks the answer to the one still waiting. It then has to win the claim before it writes the response or marks the input delivered. If the server won, the blocker closes and `answer` returns `false`, so `deliverInputs` sends the input as ordinary goal input. **Race that remains:** if the worker claims the question just before the client's cancellation reaches the server, the input counts as an answer to a call the client has already given up on. Nothing in ProPR can prevent this, because the client cancels on its own and doesn't wait for the server. Every other stale window now ends at the claim check. **Tests:** five new tests in `test/claudeOperatorQuestions.test.ts` drive the real inline server: - the question is cancelled while the turn is active, the blocker closes on `sync`, and the next input is not used as an answer. - the cancellation arrives with no `sync` before the input is sent. - one of two waiting questions is cancelled, and the input still answers the other. - the question is cancelled before the worker first sees it, so no blocker is created. - a late cancellation doesn't overwrite an answer that was already claimed. All five fail against the previous code. With the fix, the file passes 26/26, `test/claudeNativeGoal.test.ts` passes 27/27, the `packages/core` typecheck passes, and eslint `--max-warnings 0` is clean for the two changed source files. **Separate discovery, not changed:** the timeout and `closeOpen` paths don't check the claim. If the client cancels just as a question times out, the blocker is recorded as `question_timed_out` instead of `provider_resolved`. That only affects the audit label; no input is lost. There's no visual preview because the UI didn't change. PR: #3452 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5
…e question, a cancellation that arrives afterwards no longer makes the server throw that answer away. I fixed F3. If the operator's answer has already claimed the question, a cancellation that arrives afterwards no longer makes the server throw that answer away. **The fix** (`packages/core/src/agents/impl/utils/operatorQuestionMcpServer.ts`, in the inline server source): - **Who decides:** `claimCancelled` now returns whether it won the claim. It creates the claim file exclusively (`open(..., 'wx')`), and only creating that file counts as winning. What gets written into it afterwards is just for information, which matches how the worker already reads claims: any claim it didn't create counts as a cancellation. - **The cancellation handler** sets `wait.cancelled` only if `claimCancelled` won. If the claim already exists, it belongs to the worker's answer, so the call keeps polling and returns the answer once the response file appears. This also covers a cancellation that lands after the claim is created but before the response is written. - **Duplicate notifications:** a separate `cancelling` flag stops two notifications for the same call from both trying to claim. - **If the claim can't be written** for any reason other than "already exists", the call keeps waiting rather than cancelling. Nothing was recorded, so the worker may still claim the question for an answer, and the server's own deadline still applies. **Checked for the same problem elsewhere:** the worker's `answer` already lets the exclusive claim decide (`claimForAnswer`, and `closeCancelled` when it loses). Timeouts and `closeOpen` write `no_answer`/`closed` without taking a claim. A cancellation arriving after those ends the call without using up any input, so they don't have this problem. **Tests** (`test/claudeOperatorQuestions.test.ts`): - The existing late-cancellation test now also checks that the tool returns `The operator answered:\nDone.`, that the input is marked delivered, and that the blocker is resolved as `answered`. - A new test covers a cancellation between the claim and the published answer. It creates the `answered` claim by hand, sends the cancellation, checks the call is still waiting after 1.5 s (three polls), then publishes the response and checks the call returns that answer. - Both tests fail against the previous server code and pass with the fix. **Verification:** `claudeOperatorQuestions.test.ts` passes (27/27), `claudeNativeGoal.test.ts` passes (27/27), `tsc --noEmit` for `packages/core` is clean, and eslint `--max-warnings 0` is clean for the changed core file. The root `test/` directory isn't covered by any eslint config. As the finding says, an MCP client that cancels a call may still ignore the response. This fix only makes sure the server doesn't throw the answer away on its own side. There's nothing visual to preview. PR: #3452 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5
… has to win the same exclusive claim that cancellation uses before it returns "no answer". So a timed-out question can no longer swallow the operator's next input, and its "Needs you" blocker closes. I fixed F4. When the server's own deadline runs out, it now has to win the same exclusive claim that cancellation uses before it returns "no answer". So a timed-out question can no longer swallow the operator's next input, and its "Needs you" blocker closes. **Server side** (`operatorQuestionMcpServer.ts`) - When the deadline passes, the server tries to create the claim file with the content `timed_out`. It returns no-answer only if it wins. - If the worker's answer claim got there first, the server waits up to 30 more seconds for that answer to be written, then gives up. Before, it would have dropped an answer that was already being delivered. - Cancellation and timeout now share one claim function. It writes the content to a temporary file and hard-links it into place, so the claim never exists without its content. If hard links aren't available, it falls back to the old create-then-write method. **Worker side** (`claudeOperatorQuestions.ts`) - The worker now reads what the claim says. A `timed_out` claim closes the blocker as `question_timed_out`; any other claim it didn't create still closes as `provider_resolved`. - This check already runs in three places, and all of them now handle timeouts: - when a request is first discovered, so a question that timed out before the worker saw it never becomes a blocker. - at the end of `sync`, after the slow `reportBlocker` await in your scenario. - at the start of `answer`, and again if the worker loses the answer claim. **Tests** (`test/claudeOperatorQuestions.test.ts`), four new regressions: - **Your scenario:** blocker reporting is held until the server has returned no-answer. The blocker closes as `question_timed_out`, the next input returns `false`, nothing is marked delivered and no response file is written. - **No sync in between:** an input that arrives after a server timeout the worker hasn't synced yet is still not consumed. - **Late discovery:** a request the server already timed out never becomes a blocker. - **Answer claim wins:** when the worker claimed the answer just before the deadline, the call keeps waiting and returns the answer. **Verification:** all four new tests fail on the previous code and pass now. The operator-questions suite passes (31/31), as does `test/claudeNativeGoal.test.ts` (27/27). The core and root typechecks are clean, and core eslint `--max-warnings 0` is clean for both source files. The root eslint config skips files under `test/`, so the test file wasn't linted. **One leftover edge case:** if hard links aren't available and the worker reads a timeout claim in the brief moment before its content is written, the blocker is labelled `provider_resolved` instead of `question_timed_out`. It still closes and the input is still not consumed. No other independent problems turned up, and the UI didn't change, so there's no preview. PR: #3452 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5
…e-goal-runs-an--20261111-2200-pg6 [3435 by Claude Opus 5.5] Give Claude goal runs an ask_operator tool backed by goal blockers
…` journal entry for every blocker that is still open for its goal's current attempt. A cursorless `wait_goal` with `until: "blocked"` now matches those blockers immediately after an upgrade. I fixed F1. When the migration runs, it now writes an `open` journal entry for every blocker that is still open for its goal's current attempt. A cursorless `wait_goal` with `until: "blocked"` now matches those blockers immediately after an upgrade. **The fix** is in `packages/core/src/db/migrations/20261112000000_journal_goal_blockers.js`. Before creating the triggers, `up` copies existing blockers into `goal_events` as `kind: 'blocker'`, `state: 'open'` entries, oldest first. It only copies a blocker if: - it is still `open`, - its goal is not finished, and - its claim and generation match the goal's. These are the same checks `openBlockerEvent` uses. The existing `down` already deletes all blocker events, so it needed no change. I left out stale-attempt blockers and blockers of finished goals on purpose. The cursor-based wait loop matches any `blocker`/`open` event without checking the attempt. If I backfilled those blockers, a wait whose cursor was taken before the upgrade would see new `open` events for blockers nobody is waiting on, and match wrongly. Under the triggers, those blockers would have been journaled back when their attempt was current, so leaving them out produces the journal the triggers would have written. **New regression test:** `packages/api/test/goalBlockerJournalUpgrade.test.ts`. It runs all migrations, rolls back just this one, and inserts five blockers: a current one, a stale-attempt one, a closed one, one on a finished goal, and a current one on a second goal. Then it migrates again and checks that: - only the two current blockers get exactly one opening entry each. - both match `until: blocked` immediately, with no cursor. - updating only `last_observed_at` still writes nothing, so a cursor past the opening times out. - resolving a backfilled blocker gives the pair `open` → `resolved`, and the wait then times out. - the finished goal and the stale or closed blockers get no entries. **Checks run:** - The new file, `goalBlockerNotifications.test.ts` and `test/goalMigration.test.ts` all pass (15/15). - With the backfill temporarily removed, 2 of the 3 new tests fail. - `packages/api` ESLint at 0 warnings is clean for the new file, and `tsc` reports nothing for it. I made no visual preview, because a database migration has nothing to show on screen. PR: #3468 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5
…api/test/mcpObservableSurface.test.ts`, now passes locally and ESLint with `--max-warnings 0` is clean for the file. I fixed the Shard 4/4 failure. The failing test, `packages/api/test/mcpObservableSurface.test.ts`, now passes locally and ESLint with `--max-warnings 0` is clean for the file. **Cause:** the test checks every backticked lowercase name in `docs/mcp.md`. Each one has to be either a ProPR MCP tool an admin can see, or a word on the test's list of non-tool names. Commit `fa22b4f3a` documented the new `wait_goal` blocker condition, and that added five words the list didn't have: `blocked`, `blocker`, `open`, `resolved` and `superseded`. I reproduced the failure locally first; it stopped at `blocked`. **Fix:** I added those five words to the test's non-tool list, next to the other `wait_goal` fields, with a comment saying what they are. The docs are unchanged. This is the same kind of fix as the earlier Shard 2/4 failure with `ask_operator`. I only ran this one test. The rest of shard 4 already passed in CI (245 of 246), so I didn't rerun it. There are no visual previews, because this change only touches a test. PR: #3468 Comment by: @propr-dev[bot] (ID: 6822951772) Comment by: @propr-dev[bot] (ID: 6822956944) Comment by: @github-actions[bot] (ID: 6822957453) Model: Claude Opus 5.5
…-operator-when--20261112-1025-3cs [3436 by Claude Opus 5.5] Notify the operator when a goal needs an answer
✅ Epic ready for final merge: Let Claude goal runs ask the operator a questionAll 2 child PRs have been merged into this epic branch. This epic PR is ready for final review and merge. Posted automatically by ProPR |
|
🔀 Resolved merge conflicts from Conflicting Files
Resolution SummaryI resolved the conflicts in all three files. A repo-wide search finds no conflict markers left. The API package typechecks with All three conflicts happened because both branches added things in the same places:
Neither side changed the other's logic, so in every case I kept both.
|
Automatically resolved merge conflicts after merging target branch into PR branch. Resolved conflicts in: - CHANGELOG.md - packages/api/mcp/toolsManagement.ts - packages/api/routes/configSettings.ts PR: #3460 Model: Claude Opus 5.5
|
🔀 Resolved merge conflicts from Conflicting Files
Resolution SummaryI resolved the one merge conflict, in What the conflict was about: both branches added new entries at the top of
How I resolved it: I kept all five entries with their wording unchanged. The PR's entry comes first, followed by Why: the two sides describe separate features, so neither replaces the other, and a changelog has to list everything that shipped. Putting the PR's entry first keeps it where the PR placed it, and Check: no conflict markers remain, and the section is a well-formed Markdown list. Only 🤖 Resolution Details
System-triggered merge conflict resolution |
Automatically resolved merge conflicts after merging target branch into PR branch. Resolved conflicts in: - CHANGELOG.md PR: #3460 Model: Claude Opus 5.5
|
CI failed: Packaged Connect (darwin-x64) Please investigate and fix this CI failure.
Failure evidence
|
|
CI failed: Packaged Connect Discovery Guard Please investigate and fix this CI failure.
Failure evidence
|
|
ℹ️ Analyzed the follow-up request by @propr-dev[bot] Analysis SummaryI didn't change any code: this failure was a network drop on the macOS runner, not something in this branch. What failed: in the darwin-x64 job, Why it's not the branch:
What's needed: someone with Actions permissions needs to re-run the failed jobs of run 43386147917. I tried There's no visible change, so I made no preview. No code changes were necessary based on the current state of the branch. 🤖 Analysis Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
|
ℹ️ Analyzed the follow-up request by @propr-dev[bot] Analysis SummaryThe failure is a network problem on the CI runner, not a bug in this branch, so I didn't change any code. What failed: The guard job only reports on the four packaged-desktop jobs, and one of them failed. On commit
Why it failed: During Why it isn't this branch:
Fix: Re-run the failed darwin-x64 job ( If this download keeps failing, There's no visual change, so I made no previews. No code changes were necessary based on the current state of the branch. 🤖 Analysis Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
|
/review |
|
✅ AI Code Review Complete requested by @integry Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThis PR adds Claude operator questions through a per-attempt MCP exchange and connects goal blockers to notifications and durable goal waits. No merge-blocking code defect was verified from the supplied diff, but the PR is not yet merge-ready because current checks include two failures. ✅ Task-mode isolation — Docker argument construction explicitly excludes the injected tool from ordinary task runs, with tests covering explicit and default task mode. ✅ Answer routing and cancellation — Stored input boundaries prevent earlier corrections from becoming answers; exclusive claims coordinate answers with server cancellation and timeout. ✅ Notification lifecycle — Notifications target the goal owner, deduplicate by blocker ID, redact summaries, and include cleanup after creation to handle blockers that closed during notification delivery. This was a static review; no commands or tests were run. Both linked issue descriptions contain truncation notices, so assessment of their acceptance criteria is limited to the visible requirements. Merge blockersNo merge blockers. SuggestionsThese are optional follow-ups and are not sent to S1: 🟢 Validate the actual Claude runtimeThe tests exercise the inline MCP server directly and inspect generated launch arguments, but they do not establish that the deployed Claude runtime honors the configured per-server timeout during a long operator wait. A disposable authenticated goal covering a delayed answer, pause, and timeout would strengthen integration evidence. This is a validation follow-up, not a demonstrated code defect. S2: 🟢 Reconcile notification delivery failures
ScoreThe implementation has substantial targeted coverage and no verified code blocker. The authoritative current-head status nevertheless reports failures in Packaged Connect (darwin-x64) and Packaged Connect Discovery Guard, with five checks pending; the supplied evidence does not connect those failures to changed code. Score: 7/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
✅ Epic merged: Let Claude goal runs ask the operator a questionEpic PR #3460 has been merged into main. 2 out of 2 PRs merged into main through this epic PR. All planned epic work is now merged. Posted automatically by ProPR |
Let Claude goal runs ask the operator a question
This Epic PR aggregates all changes for the plan: Let Claude goal runs ask the operator a question
Issues in this Epic
Auto-close
When this PR is merged, the following issues will be automatically closed:
Fixes #3435
Fixes #3436
Created automatically by ProPR