Repository navigation
Conversation
This comment was marked as spam.
This comment was marked as spam.
|
Thanks for the careful read. I pushed a small follow-up in
On the first point: the existing delayed-timeout test was already asserting that the delivery channel receives the final announced content via |
Greptile SummaryThis PR changes Confidence Score: 5/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/infra/fs-pinned-write-helper.ts
Line: 371-376
Comment:
**`hadExistingTarget` not reset on TOCTOU-ENOENT**
If `fs.stat(targetPath)` succeeds (setting `hadExistingTarget = true`) but then `fs.link` or `fs.copyFile` throws `ENOENT` (e.g. file deleted between stat and link), the outer catch swallows the ENOENT without resetting `hadExistingTarget`. The code then continues with `hadExistingTarget = true` but no backup on disk. Later, if a size mismatch occurs, `fs.rename(backupPath, targetPath)` on line 382 throws `ENOENT` — raising the wrong error and leaving the new-but-wrong-size content in place rather than surfacing a clean `write size mismatch`.
This only triggers in an extremely rare TOCTOU race and is limited to the JS fallback path (`runPinnedWriteFallback`), but the fix is straightforward:
```suggestion
} catch (error) {
if ((error as NodeJS.ErrnoException).code !== "ENOENT") {
await fs.rm(tempPath, { force: true }).catch(() => {});
throw error;
}
hadExistingTarget = false;
}
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "Clarify bounded follow-up wait in sessio..." | Re-trigger Greptile |
| } catch (error) { | ||
| if ((error as NodeJS.ErrnoException).code !== "ENOENT") { | ||
| await fs.rm(tempPath, { force: true }).catch(() => {}); | ||
| throw error; | ||
| } | ||
| } |
There was a problem hiding this comment.
hadExistingTarget not reset on TOCTOU-ENOENT
If fs.stat(targetPath) succeeds (setting hadExistingTarget = true) but then fs.link or fs.copyFile throws ENOENT (e.g. file deleted between stat and link), the outer catch swallows the ENOENT without resetting hadExistingTarget. The code then continues with hadExistingTarget = true but no backup on disk. Later, if a size mismatch occurs, fs.rename(backupPath, targetPath) on line 382 throws ENOENT — raising the wrong error and leaving the new-but-wrong-size content in place rather than surfacing a clean write size mismatch.
This only triggers in an extremely rare TOCTOU race and is limited to the JS fallback path (runPinnedWriteFallback), but the fix is straightforward:
| } catch (error) { | |
| if ((error as NodeJS.ErrnoException).code !== "ENOENT") { | |
| await fs.rm(tempPath, { force: true }).catch(() => {}); | |
| throw error; | |
| } | |
| } | |
| } catch (error) { | |
| if ((error as NodeJS.ErrnoException).code !== "ENOENT") { | |
| await fs.rm(tempPath, { force: true }).catch(() => {}); | |
| throw error; | |
| } | |
| hadExistingTarget = false; | |
| } |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/infra/fs-pinned-write-helper.ts
Line: 371-376
Comment:
**`hadExistingTarget` not reset on TOCTOU-ENOENT**
If `fs.stat(targetPath)` succeeds (setting `hadExistingTarget = true`) but then `fs.link` or `fs.copyFile` throws `ENOENT` (e.g. file deleted between stat and link), the outer catch swallows the ENOENT without resetting `hadExistingTarget`. The code then continues with `hadExistingTarget = true` but no backup on disk. Later, if a size mismatch occurs, `fs.rename(backupPath, targetPath)` on line 382 throws `ENOENT` — raising the wrong error and leaving the new-but-wrong-size content in place rather than surfacing a clean `write size mismatch`.
This only triggers in an extremely rare TOCTOU race and is limited to the JS fallback path (`runPinnedWriteFallback`), but the fix is straightforward:
```suggestion
} catch (error) {
if ((error as NodeJS.ErrnoException).code !== "ENOENT") {
await fs.rm(tempPath, { force: true }).catch(() => {});
throw error;
}
hadExistingTarget = false;
}
```
How can I resolve this? If you propose a fix, please make it concise.5add704 to
f64211f
Compare
f64211f to
76796dc
Compare
|
Just rebased onto current |
76796dc to
a0351b3
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a0351b3871
ℹ️ 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".
| if (result.status === "timeout") { | ||
| startA2AFlow(undefined, runId); | ||
| return jsonResult({ | ||
| runId, | ||
| status: "timeout", | ||
| error: result.error, | ||
| status: "accepted", |
There was a problem hiding this comment.
Treat terminal wait timeouts as failures, not accepted
agent.wait uses status: "timeout" for both “still running past caller timeout” and terminal aborted runs (see src/gateway/server-methods/agent-job.ts where aborted end events map to timeout). This branch now converts every timeout into status: "accepted" and starts delayed announce flow, so a run that has already ended with timeout is reported as pending success and never produces the expected follow-up delivery. In practice, when the target agent run times out/aborts, callers can get a misleading accepted result instead of a failure signal.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8676fd294b
ℹ️ 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".
| }); | ||
|
|
||
| if (result.status === "timeout") { | ||
| startA2AFlow(undefined, runId); |
There was a problem hiding this comment.
Pass baseline when deferring timed-out waits to A2A flow
This timeout branch now starts delayed announce delivery with startA2AFlow(undefined, runId) but drops the pre-run snapshot captured in baselineReply. The delayed path in runSessionsSendA2AFlow then calls readLatestAssistantReply(...) (src/agents/tools/sessions-send-tool.a2a.ts) and treats that as the run reply, which can be an old assistant message when the timed-out run finishes without emitting new assistant text. In that case, sessions_send may announce stale content from earlier history to the requester channel, which is a new regression introduced by enabling timeout-to-announce flow here.
Useful? React with 👍 / 👎.
|
CI is now fully green (94/94) after the rebase onto current |
|
This pull request has been automatically marked as stale due to inactivity. |
|
Codex review: found issues before merge. Summary Reproducibility: yes. Current main can be reproduced with a mocked Next step before merge Security Review findings
Review detailsBest possible solution: Land one consolidated fix that distinguishes soft wait-window expiry from terminal run timeout, preserves the baseline reply guard for delayed reads, keeps announce delivery alive only for proven in-flight accepted runs, and adds the required changelog entry. Do we have a high-confidence way to reproduce the issue? Yes. Current main can be reproduced with a mocked Is this the best way to solve the issue? No. The direction is valid for soft wait-window expiry, but this implementation is not the safest fix because it treats all timeout results as accepted and reads delayed replies without the pre-run baseline; #68196 should be considered during consolidation. Full review comments:
Overall correctness: patch is incorrect What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 929df0f5567f. |
Summary
sessions_sendwait timeouts as pending delivery instead of an immediate hard failureProblem
sessions_sendcurrently returnsstatus: "timeout"as soon as the initialagent.waittimes out. In the agent-to-agent path, that can be premature: the target run may still finish moments later, but the calling agent has already received a hard timeout and may emit a user-facing failure likeDELEGATION_FAILED:socrates:timeout.Reproduction
sessions_sendfrom one agent to another withtimeoutSeconds > 0.Expected
If the target run is still in flight after the initial wait window,
sessions_sendshould keep delivery pending and allow the follow-up announce flow to finish when the delayed reply arrives.Actual
The tool returned
status: "timeout"right away, which encouraged the caller to post a failure even though the target reply could still be delivered successfully.Fix
When the initial
agent.waittimes out, keep the tool result inaccepted/pending-delivery state and start the existing announce flow with the in-flightrunId. The announce flow performs its own follow-up wait and can still fetch and relay the delayed reply.The same pending-delivery treatment now also applies when the wait RPC itself hits a gateway timeout after the target run has already started.
Validation
vitest --root /tmp/openclaw-sessions-send-timeout run src/agents/openclaw-tools.sessions.test.ts -t "sessions_send keeps delayed announce delivery alive after a wait timeout"vitest --root /tmp/openclaw-sessions-send-timeout run src/agents/openclaw-tools.sessions.test.ts