feat: add configurable trajectory flush timeout for reasoning traces#78133
feat: add configurable trajectory flush timeout for reasoning traces#78133stevenepalmer wants to merge 3 commits into
Conversation
|
Codex review: needs real behavior proof before merge. Summary Reproducibility: yes. for the PR defect by source inspection: the PR head schedules one timeout and the callback clears it without scheduling the next tick. The added test advances only one interval, so it does not prove periodic behavior. Real behavior proof Next step before merge Security Review findings
Review detailsBest possible solution: If maintainers accept this opt-in trajectory flush interval, implement lifecycle-safe repeating flush semantics with docs, changelog, focused tests, and real configured runtime proof; otherwise solve the linked cleanup-timeout/session latency concern in the owning cleanup or session-store path. Do we have a high-confidence way to reproduce the issue? Yes, for the PR defect by source inspection: the PR head schedules one timeout and the callback clears it without scheduling the next tick. The added test advances only one interval, so it does not prove periodic behavior. Is this the best way to solve the issue? No. The current patch is not the narrowest maintainable solution until the timer repeats correctly, the config/env surface is documented and approved, and the contributor shows real configured runtime behavior. Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 97b07eaeaf38. |
3615512 to
d9008e9
Compare
- Add trajectory.flushTimeoutMs config option in openclaw.json - Add OPENCLAW_TRAJECTORY_FLUSH_TIMEOUT_MS env var fallback - Implement periodic flush in trajectory recorder based on timeout - Create TrajectoryConfig type definition Closes openclaw#78126
…h timeout Verifies that when flushTimeoutMs is set in config, the trajectory recorder schedules a flush after the configured interval using fake timers.
…mer, no post-flush reschedule
d9008e9 to
e3dd620
Compare
|
@joshavant CI is green on this one, and it stays tightly scoped to trajectory flush timeout behavior. Real behavior proof and focused validation are in the PR body. Would appreciate your review when you have a chance. |
|
Closing this to avoid duplicate/superseded churn. The linked issue state and follow-up history point to existing work already covering the remaining path here (notably #77187), so this PR should not stay open as a competing line. |
Summary
Describe the problem and fix in 2–5 bullets:
trajectory.flushTimeoutMs, wired it into config typing/schema, and validated periodic flush behavior with focused runtime tests.flushTimeoutMsis unset.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Real behavior proof (required for external PRs)
openclaw/openclawon Linux with branchpr-78133.git checkout pr-78133node scripts/run-vitest.mjs run --config test/vitest/vitest.unit-fast.config.ts src/trajectory/runtime.test.ts --reporter=verboseOpenClawConfigand the zod schema so the setting is actually usable end-to-end.trajectory.flushTimeoutMsconfig path and no periodic-flush runtime coverage.Root Cause (if applicable)
Regression Test Plan (if applicable)
src/trajectory/runtime.test.tsflushTimeoutMsis configured, the runtime periodically flushes buffered events without waiting for shutdown or turn/session end.src/trajectory/runtime.test.tsnow includesfires periodic flush after flushTimeoutMs.User-visible / Behavior Changes
Users/operators can now configure
trajectory.flushTimeoutMsto periodically flush in-flight trajectory events to disk during long reasoning sessions. Default behavior remains unchanged when unset.Diagram (if applicable)
Security Impact (required)
Yes/No) NoYes/No) NoYes/No) NoYes/No) NoYes/No) NoYes, explain risk + mitigation: N/ARepro + Verification
Environment
trajectory.flushTimeoutMs=<set in test scenario>Steps
pr-78133.node scripts/run-vitest.mjs run --config test/vitest/vitest.unit-fast.config.ts src/trajectory/runtime.test.ts --reporter=verbose.Expected
Actual
Test Files 1 passed,Tests 9 passed, including the periodic flush scenario.Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
pr-78133.Review Conversations
Compatibility / Migration
Yes/No) YesYes/No) YesYes/No) Notrajectory.flushTimeoutMsmay be added; otherwise no action required.Risks and Mitigations
Real behavior proof
The updated test advances fake timers through three consecutive 5-second intervals and asserts
flushCalls.toHaveLength(3), proving the timer repeats for the lifetime of the recorder. Previously the test only checked one tick.Behavior or issue addressed: Periodic trajectory flush timer was single-shot — only fired once per session.
Real environment tested: Node.js v24.14.0, vitest v4.1.5, /tmp/pincer-openclaw on Linux.
Exact steps or command run after this patch:
node scripts/run-vitest.mjs run --config test/vitest/vitest.unit-fast.config.ts src/trajectory/runtime.test.ts --reporter=verboseAfter-fix evidence: Terminal output above — all 9 tests pass including the repeating-interval test.
Observed result after fix: Flush timer reschedules itself after each tick; three consecutive intervals all fire.
What was not tested: Live gateway run with a real long-running session; the timer behavior is covered by the fake-timer integration test.