Repository navigation
FIX-1661: the engine records each request's action result; the DevTool row reads it - #2429
Conversation
… DevTool row reads it (FIX-1661) The engine writes the action's result on the request record in the same write as the final status, through one typed settlement, and the session request list returns it (output only with include_result_output). The DevTool's Tasks-tab row reads status + result from the polled list; the trace reconstruction and the stream-log cache are deleted. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014LohgYyHsXCYQd6kABH11N
…ment the stored result (FIX-1661) The goal check under goals/devtool-workforce-visibility/reads-a-row-actions-result drives the shipped DevTool in Chromium over a no-model fixture flow served by fsdev dev, one leg per case a trace reading got wrong, and a no-result control that strips `result` from the listing and must fail every leg. Docs: listSessionRequests in the client API reference, the stored result in manual flow execution, the DevTool row paragraph, the client README comment, and the server-and-client policy list. Changesets for engine, client, devtool. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014LohgYyHsXCYQd6kABH11N
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
jhoffner
left a comment
There was a problem hiding this comment.
Second look + architecture pass (read-only review; nothing was run locally)
Verdict: the approach is right. Store the result with the terminal status in one write, and delete the DevTool's trace/stream rebuild. The typed RequestSettlement is a better guard than the totality test it replaced. Findings below, most important first. They are for the implementing agent to triage.
Answer to the PR's open question: other terminal writers
I grepped engine/src for terminal request-record writes outside runAction and terminateUnenqueuedRequest. Two remain that don't go through settleRequestRecord/buildRequestActionResult:
execution/request-recovery.ts:~105(stale-request sweep, writesinterrupted)stores/subscribe-helpers.tsonly synthesizes aninterruptedevent, so it is not a record writer.
The recovery sweep is interrupted, which carries no result by design, so it is correct today. But it is the one terminal writer that bypasses the typed helper, so it isn't covered by the compile-time guarantee the PR claims. Suggest routing it through a shared { status: "interrupted" } settlement, or adding a one-line comment there saying why it is exempt. RequestSettlement is not exported from engine/index.ts. Adapters and other packages (bullmq, next) that write request records can't reach it.
1. Unbounded result storage and list payload (worth a decision)
recordableOutput JSON-copies every completed action's output onto the request record, with no size cap. include_result_output=true (which the DevTool row poll now sends) returns every listed request's full output on every poll.
- Storage: request records grow with the largest action output ever returned, forever, in memory/sqlite/postgres alike.
- Wire: the poll cost scales with
sum(output sizes)across the session's request list, not with the rows on screen.
The DevTool only needs the outputs for the requests behind the rows it is showing, and only needs {ok:false}-shaped ones to render a refusal. Options: (a) a byte cap in recordableOutput that degrades to outputNotRecorded: true (the type already has that escape hatch), plus (b) scoping include_result_output by requestIds, or having the row fetch one request's result lazily. Option (a) alone is a small change and closes the storage half. Please at least state the cap decision in the PR, since it is a persisted-shape choice (BP-030).
2. runAction's in-process return changed for every caller
output is now populated on the failed path when the action answered before a hook failed the request. I checked the callers I could find. cli/src/commands/run.ts, mcp/src/result-formatting.ts and the bullmq/workforce/in-process callers all check result.error first, so nothing breaks. One visible side effect: fsdev run on a failed run now emits output: <answer> in the FlowRunResult (output: result.output ?? null) where it used to emit null. It's arguably right, but it is a CLI output-contract change with no test and no changeset line. Add a CLI-level assertion or note it in the engine changeset.
3. Stored copy and in-process value can disagree
The record stores a JSON round-trip (Date → string, undefined keys dropped, NaN → null), while runAction returns the raw result.output (actionAnswer?.output). The PR text says "the stored answer and the one an in-process caller receives use one vocabulary", which holds for keys but not values. Either return the recorded copy on the failure path, or soften the doc comment on RequestActionResult. Not blocking.
4. settleRequestRecord swallows nothing, but a failed settle write loses the status
settleRequestRecord puts status and result in one write. That is good for pollers, but if recordableOutput throws somewhere other than stringify (e.g. a toJSON that throws is caught, but a getter that throws during JSON.parse reviver is not applicable; fine), the guard is OK. I found no defect here, just confirm the catch around JSON.stringify is covered by a test with a throwing toJSON in addition to BigInt/cycle. The listed tests mention BigInt and cycle only.
5. Architecture: keep the stringly "refusal" convention out of the engine, and make sure it stays out
classify() in devtool/lib/task-actions.ts still owns {ok:false} / {outcome:"declined"} interpretation. That is the right side of the line (engine stores, reader interprets), and the engine doc comment says so. But hasOutput is computed in session-routes.ts as a route-level decoration on a persisted type and only appears in the client type. Consider defining ListedRequestActionResult once in stores/types.ts (or the contracts layer) next to RequestActionResult so client and engine derive from one source rather than mirroring (SessionRequestResult is a hand-copied shape).
6. Smaller items
patchRequestRecordis now a one-line wrapper overwriteRequestRecordPatchwhose only job is a narrower type. Fine, but the two names are easy to confuse; a short comment onwriteRequestRecordPatch("internal: use patch/settle") would help.terminateUnenqueuedRequestcallsnormalizeError(cause, { scope: "request" }). Check that this cannot leak internal error detail (stack,details) into a list response that other tenants' callers withuserIdaccess can read. The stored shape is only{code,message}, so this looks OK, but the message of a raw thrownErrorat the admission layer can include store keys or ids. Worth a look under BP-031/multi-tenant (BP-035).- Followups the PR itself names: update BR-5's "Proved by" cell in the spec, and file the board-provenance issue. Both should exist before merge so they aren't lost.
- Docs were drafted without
docs-writer/docs-editor, as the PR says. Run them before release per the repo rule.
Not flagged
The result exclusion from ConditionalRequestFields, the execution_error default code, and the DevTool's not-reported wording are all sound.
Generated by Claude Code
There was a problem hiding this comment.
Code Snob — already tight. No POC.
I read packages/engine/src/execution/request-action-result.ts, the settle/patch split in runAction.ts, withListedResult in session-routes.ts, terminateUnenqueuedRequest in createInboundTransportHost.ts, outcomeOf in packages/devtool/src/react/lib/task-actions.ts, Outcome / describeOutput in task-row-actions.tsx, and the rowOutcomeSources projection in DevToolPanel.tsx.
A rewrite would not shrink this contract:
- The trace walk,
mergeRawItems, and the stream-log cache are already gone. What is left inoutcomeOfis the status-then-result read the row still has to make: refusal, declined write, failed after an answer, nothing recorded. buildRequestActionResultis the one builder bothsettleRequestRecordand the transport host call. Moving it back intorunActioncopies it onto the host.patchRequestRecordis the one-line type fence so a terminal status cannot be written without its result. That is the totality check this PR replaced. Folding it intowriteRequestRecordPatchopens that hole again.withListedResultis theinclude_result_outputstrip.hasOutputis what the list still sends when the value is left off.- Renaming
requestIdtoiddeletes the four-line map in the panel and puts the same field back on every fixture. Tie. describeOutputhas one caller. Inlining it does not change the contract.
Left the typed settlement and the no-fallback row read as they are. Both are already decided on this PR.
Sent by Cursor Automation: Code Snob
There was a problem hiding this comment.
Problem and approach
The bug was real: DevTool row outcomes were inferred from traces, item refs, and stream timing, which breaks for transient blocks, hook ordering, handover, and “open the panel later.” Persisting the action result on the request record at terminal settlement and reading it from the session request list is the straightforward fix—and the diff removes a lot of DevTool complexity (mergeRawItems, trace/ref resolution) rather than adding a parallel inference path.
I considered simpler alternatives:
| Alternative | Why I’m not asking for it |
|---|---|
| Keep trace/stream reconstruction, patch edge cases | More branches, same race class; FIX-1661’s goal anti-game (no-result) correctly rules this out. |
Inline buildRequestActionResult only in runAction |
createInboundTransportHost also settles requests; a shared request-action-result module is warranted. |
Always return full output on list (no include_result_output) |
Would tax every poller; mirroring include_items is consistent and documented. |
| Drop the goal harness, rely on integration tests only | The Playwright goal is heavy (~500 lines) but encodes the control matrix and proxy anti-game; I’d treat shrinking it as a follow-up, not a merge blocker. |
Verdict: This is the right direction. Surface area (store field, list projection, client flag, conformance tests) matches a durable contract; the DevTool side got simpler.
Simplify / follow-ups (non-blocking)
- Three changesets — BP-022 allows one multi-package fragment; consolidating
request-action-result-{engine,client,devtool}.mdwould reduce release noise. - Terminal writes — Setup failure in
runActionandterminateUnenqueuedRequestin the inbound host still hand-build{ status, result }while normal paths usesettleRequestRecord; a small shared helper would avoid a third drift path later. recordableOutput— After theoutput === undefinedguard, thetext === undefinedbranch looks unreachable; worth deleting or commenting if you’re keeping it for a reason.- DevTool poll payload —
includeResultOutput: trueon every session list refresh pulls every recorded output for the whole session, not just row-action request IDs. Fine for typical debugging; if sessions get long, consider a scoped API or lazy read (inline comment). - Duplicate wire types —
RequestActionResultvsSessionRequestResultduplicate the same table; optional later move of the shared core tocontracts(not required for this PR). incomplete+ output —outcomeOftreats any non-completedstatus asfailedeven whenresult.outputexists; tests match that; flag only if product wantsincompletesuccesses to show asok.
Engine tests for request-action-result / session-requests-result pass locally on this branch.
Nice work—the persistence + opt-in list projection is cleaner than extending trace heuristics.
Sent by Cursor Automation: Review For Best Approach
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5851e3f5f5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
… every final-status writer (FIX-1661) Review round 1 on the action-result PR: - The stored output is capped at MAX_RECORDED_OUTPUT_BYTES (64 KiB of UTF-8 JSON); past it the record says outputNotRecorded, so records and listings that carry outputs stay bounded. - An output JSON would silently change (NaN, +/-Infinity, a function or symbol, an undefined array slot) is recorded as outputNotRecorded instead of storing a different value. - settledRecordFields pairs the status with its result for every final-status writer: settleRequestRecord, the setup-failure CAS settle, the transport host's unenqueued termination, and the recovery sweep. - RequestActionResult's doc says the stored copy and the live value share keys, not always values. - fsdev run: a run a completion hook failed after the action answered reports that answer as output; asserted at the CLI. - One multi-package changeset in place of three. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014LohgYyHsXCYQd6kABH11N
|
Reply to the second look (review 5360652076). All code changes are in 65ddb90. Other terminal writers. Fixed. The stale-request recovery sweep now builds its 1. Unbounded storage. Fixed with option (a). 2. 3. Stored copy vs live value. Fixed as you suggested, by softening the 4. Throwing 5. One source for the listed shape. Not in this PR. 6. Smaller items. Verified on 65ddb90:
Generated by Claude Code |
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014LohgYyHsXCYQd6kABH11N
|
@codex review Generated by Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 70cc08534c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…not recorded (FIX-1661)
Review round 3 on the action-result PR:
- Drop the 64 KiB output cap. The spec (D1, PLAN) keeps storage uncapped
and makes only an opted-in listing carry outputs.
- A Map, Set, Error, RegExp or typed array output is recorded as
outputNotRecorded: JSON writes them as {} or index keys without
visiting their contents.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014LohgYyHsXCYQd6kABH11N
|
@codex review Generated by Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4620725901
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…(FIX-1661) Review round 4: deleting the stream-log cache made a finished request's transient trace vanish from the inspector views once the list refresh landed. PLAN S7 keeps the cache when those tabs need it and cuts only the row's use. mergeRawItems and streamRawItems are back for requestGroups; rows still read only the recorded status and result. The panel test asserts both, and goes red with the merge removed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014LohgYyHsXCYQd6kABH11N
|
@codex review Generated by Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c096773554
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…fore completion hooks (FIX-1661) Review round 5: the record's JSON copy was taken at settle time, after the completion hooks, so a hook that mutated the returned object changed the recorded answer (PLAN S3 captures before hooks). recordOutput() now takes the snapshot when the action answers; RequestSettlement carries that RecordedOutput for both the completed and the answered-then-failed settlements. The new test goes red with the snapshot taken at settle. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014LohgYyHsXCYQd6kABH11N
|
@codex review Generated by Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b9fdfeafa7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Resolves the conflict with main's incarnation-fenced terminateUnenqueuedRequest: it keeps FIX-1661's typed ending (cause recorded as the result's error) and takes main's expectedIncarnation parameter. FIX-1660's panel test now asserts the row's answer from the recorded result and the stream-only trace in the Stream tab. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014LohgYyHsXCYQd6kABH11N


The problem
When you run an action from a task's row in the DevTool, the row is supposed to show what the action came to: done, refused in its own words, or failed and why. The engine never recorded that, so the DevTool rebuilt it from traces and the live stream. Twelve review rounds on the rows each found a case where the rebuild got it wrong: a transient block, completion hooks, a value held by reference, a suspended request, a second action taking the stream. A client reading a session's history had the same gap: it could see that a request completed, but not what it returned.
What this does
When a request ends, the engine stores the action's result (
outputand/orerror) on the request record, in the same write as its final status. The session's request list returns it: every entry says whether the request failed, why, and whether it answered. The answer itself comes back only when the caller asks for it withincludeResultOutput, which the DevTool does.The row's rebuild from traces is deleted outright, and a row now reads its request's status and result. A request with no recorded result (an older server, or history from before an upgrade) says "No result recorded for this request." rather than guessing. The Stream and Trace tabs still show a finished request's stream-only transient traces.
It deliberately does not add board provenance to the action list. The spec recommended not now, and it gets a follow-up issue.
What's asked of you
Nothing new. This implements the approved spec (#2417) and both of its signed-off decisions.
Parts worth reviewing closely
The rest of this is for whoever reviews the code.
request-action-result.tsandrunAction.ts: the typedRequestSettlementandsettledRecordFields.patchRequestRecordcan no longer write a terminal status: writingstatus: "completed"through it is a TS2322.result, and the row would read it as no result recorded: honest, but wrong.runAction's in-process return carryoutputnext to the error.fsdev runreports it asoutputinstead ofnull. Any caller that treatedoutput !== undefinedas "succeeded" would now be wrong on that path.action: "submit", because a suspension with aresumeSchemaonly allowssubmit. I read that from the server's 409, not from docs.Persisted shape (BP-030).
resultis new and optional on the request record, and a record without it is read by its status, never as success.result.outputis a JSON copy with no size cap (D1): only a listing that opts in withinclude_result_outputcarries it. An output JSON can't hold, or would silently change, is stored asoutputNotRecorded: true, and the request keeps its status:toJSONundefinedarray slot, a Map, Set, Error, RegExp or typed arraySupersedes #2414 for the rows. That PR (still open) fixes how a row's answer was merged from the stream, and rows no longer read the stream at all here. Its regression test is replaced by "reads a row's answer from the listed request's recorded result, never from the stream". The stream merge itself stays, for the inspector tabs only.
Not here:
include_result_outputto request ids (possible follow-up if busy sessions show the cost)Spec:
specs/issues/FIX-1661/· Linear: FIX-1661 · follows FIX-1629 (#2347) · merges when approvedHow to review this: spec-backed implementation
This implements an approved spec. The approach and the numbered decisions in its
DECISIONS.mdare already signed off by a human, so please review the code against that direction, not the direction itself. The canonical set is retained atspecs/issues/FIX-1661/onmain. Linear links to it and to the original merged spec PR, which keeps the review history. Follow-up amendment PRs explain later changes of direction. Current architecture docs remain the authority for shipped behavior (BP-037).Most valuable here:
Already settled upstream: the approach and every decision in the spec's
DECISIONS.md, which a human approved, and the conventions indocs/contributing/best-practices.md. If a decision is wrong, raise it as a spec finding and it gets folded back; please don't re-argue it inline.Engineering calls: decided along the way, no product sign-off needed
settledRecordFieldspairs status and result for every final-status writer.outputNotRecorded: true(BR-9).undefinedbecomes{}.undefined-valued object key is left out, because it reads back the same.execution_error.FlowError.codeis optional, and the listing type promises a code.resultis excluded from the conditional-write field set. Only the settle write can set it.RequestSettlementis not exported from the engine's index. No adapter package writes a terminal request record today.runAction+continueRequestdirectly.testFlowcan't attach a durability provider.docs-writerand thendocs-editor(SHIP).Everything else: verification and files
Goal check (
goals/devtool-workforce-visibility/reads-a-row-actions-result/, Chromium on the shipped bundle, no model):GOAL_CONTROL=no-result: FAIL on every leg, and on no other.works-a-task-from-its-rowgoal re-run: PASS.Red, then green:
request-action-result.test.tswent red, then green.resultturns the "carries" case red.outcomeOftable and the row tests go red, then green.undefinedturns both scenarios red.Suites:
pnpm typecheckis clean.Files:
stores/types.ts,execution/request-action-result.ts,execution/runAction.ts,execution/request-recovery.ts,transports/host/createInboundTransportHost.ts,routes/session-routes.ts, conformanceSessionRequestResult,includeResultOutputlib/task-actions.tsrewritten; rows get{ requestId, status, result }🤖 Generated with Claude Code
https://claude.ai/code/session_014LohgYyHsXCYQd6kABH11N