Repository navigation
Conversation
Start the existing baseline capture after session admission without holding the first model request. Retain its promise at embedded and native tool boundaries, including tools materialized later, and join it before opaque backends, queue handoff, diff reads, and turn settlement. Keep read-only diff requests from starting captures and disable optional Git index locks. Release-note context: large repository sessions can prepare the first reply while preserving pre-agent workspace attribution. Deterministic tests cover held capture, mutation rejection, native and late tool callbacks, and pending diff persistence.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 8, 2026, 2:16 AM ET / 06:16 UTC (Revision 4). ClawSweeper reviewWhat this changesThe branch overlaps initial workspace diff capture with built-in inference while making tools, commands, plugin callbacks, other runtimes, and diff readers wait for capture. Example: Start a built-in agent session in a 52,834-file Git repository.
Review scores
ProductKind: Performance · Worth it: Yes Merge readiness✅ Ready for maintainer review This PR remains a useful, proven performance improvement. The prior findings are addressed, and the reviewed diff reveals no remaining actionable defect. Priority: P2 Before mergeNone. FindingsNone. Provenance
Agent review detailsHow this fits togetherOpenClaw captures the workspace's existing changes so session diffs show what the agent changed. Reply preparation starts that capture, and execution boundaries wait for it before workspace-capable work begins. flowchart TD
A[New session turn] --> B[Admit session and start baseline capture]
B --> C[Capture existing Git changes]
B --> D[Prepare built-in inference]
D --> E[Tools and plugin callbacks]
C --> E
C --> F[Native CLI and ACP dispatch]
C --> G[Session diff readers and reply settlement]
Technical reviewBest possible solution: Keep the existing generation-fenced capture owner and allow overlap only where execution owners can enforce the workspace-write barrier. Do we have a high-confidence way to reproduce the issue? Not applicable as a functional bug reproduction; the supplied paired Gateway profiling establishes the latency problem, and source confirms the baseline currently precedes inference. Is this the best way to solve the issue? Yes. Moving the wait to execution owners preserves the existing attribution contract and avoids consuming native hook deadlines without adding configuration or a competing capture implementation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 594335a38e5a. Provenance checked
TestingProof path: shipped entry point. Added test files: 10. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +230, Tests +890, Docs +2, Other 0. Total +1122 across 38 files. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
|
Keep first-turn inference overlap only for host-gated embedded tools. Join capture before native backend dispatch, direct command effects, and channel-bound ACP turns with armed claims. Preserve unavailable-baseline behavior and attribute first-turn command writes without consuming native hook deadlines.
Gate registered asynchronous hooks in the shared runner before callbacks and their error/timeout policies. Prepare synchronous transcript hooks both before early transcript admission and inside the admitted runtime registry; hook-free model setup still overlaps capture. Extract the existing capture context into a leaf and migrate its consumers to keep persistence out of plugin startup. Regressions cover real hook writes, diff attribution, prepared registries, and no-hook overlap. Keep hook and ACP files within inherited line allowances without assertion casts.
|
Closing without merging, by maintainer decision. Overlapping the session-diff baseline capture with inference is only correct if every pre-inference path that can run configured code or touch the workspace joins the capture first. Five review rounds each found another such path:
The final, safe design joins the capture before any registered callback. The bundled OpenAI provider has a policy callback, so in the default configuration the capture is back on the pre-model path. Live side-by-side on a 52,834-file repository (real OpenAI provider, reply profiler on): The safe version therefore brings no measurable speedup in the common configuration, while adding about 760 production lines and a cross-cutting ordering invariant. Main's blocking capture stays. Warm capture is now about 0.25–0.35 s; a future change could make the capture itself cheaper instead of moving it. |
What Problem This Solves
Every first turn of a session in a git repository waits for the session-diff baseline before the model request starts. In a large repository that is real latency on every new session. On a 52,834-file repository (dev Gateway on main 9aa7455, reply profiler on),
reply.capture_session_diff_baselinetook 0.8–1.2 s on warm turns, and every first turn spent that time before inference. A cold first turn reached the model only after 4.9 s, versus 2.2 s with this change. In the earlier round of this campaign, on a busier host, the same stage measured 5.3–12.5 s.The baseline only has to exist before the session can change the workspace. Inference, prompt assembly, and model streaming do not touch files, so blocking them on Git work is unnecessary.
User Impact
Why This Change Was Made
Capture already ran in a worker; the only problem was that reply initialization awaited it. The baseline owner (
src/sessions/session-diff-baseline.ts) now starts capture after authoritative session admission and publishes the in-flight promise through a reply-scoped owner. Inference may overlap capture only where the host itself gates every tool execution. Everything that can change the workspace joins the same promise at its execution owner:src/agents/harness/selection.ts). The native PreToolUse hook only asserts readiness, so no capture time is spent inside the fixed native hook and relay deadlines. On these runtimes, first-turn latency is unchanged from main./bash,!, plugin commands, exports, diagnostics, status), reset hooks, and native fast commands join the capture before executing (commands-core.tsand the fast-path owners). Plain model input does not wait there.src/plugins/hooks.ts) joins the capture before invoking any registered callback (includingbefore_model_resolveduring model setup and synchronous transcript hooks), so turns without such hooks keep the overlap.dispatch-acp.tsat 719 counted lines, under its 730 allowance.sessions.diffreaders join an active capture instead of starting one, and reply settlement keeps the dependency.Capture failure keeps its existing behavior: an unavailable baseline means the session continues without attribution filtering. Capture now passes
--no-optional-locksso it never contends with the user's own Git commands. No cache, schema, public config, protocol, or SDK shape was added.Review history:
/bashbypassed the barrier, and that waiting inside the native PreToolUse hook could exceed the Codex hook and relay deadlines. The execution-owner design above fixes both, which is why native backends no longer overlap.before_model_resolveplugin hook could write before the capture settled. That is fixed at the shared hook dispatcher.Evidence
Live (dev Gateways from main and this head 24e3ddf, fresh state, real OpenAI provider, reply profiler on;
CWD= a 52,834-file repository):Correctness, live on both runtimes: a first turn whose first action is
echo hi > <file>in a small Git repository reports exactly that file as added insessions.diff; untracked files that existed before the turn are not reported. A live/bashfirst-turn write could not run on the test Gateway because elevated commands were not allowed for WebChat (tools.elevated.allowFrom.webchat); the regressions below cover that path.Tests:
With the original production code, these fail: the premature-write regressions (
/bash,!, plugin commands, plugin hooks, native dispatch, native fast commands, reset hooks, ACP claims), and all four callback-family cases when the shared hook barrier is disabled. Core production and test types, full build, lint, format, the line-cap and assertion ratchets, and the import-cycle check (0) pass. No prompt or tool definitions changed. Autoreview is clean through P2.Production +388/-158, tests +931/-41, docs +2 (
docs/concepts/managed-worktrees.md).