Repository navigation
Conversation
…hinkFlowLab#468) ## summary - Conversations.update stamps startedAt on the assistant placeholder at acceptance and finishedAt/durationMs (monotonic) at finish entry, without touching produce()/turn(). - Conversations.trace() returns startedAt/finishedAt/durationMs per turn, null when unknown. - Tests cover complete, stop, runtime failure, rejected turns, archive, legacy data, and restart.
…try on failed begin (Refs ThinkFlowLab#468)
…ocument ThinkFlowLab#469 relation (Refs ThinkFlowLab#468)
# Conflicts: # tests/test_assistant_conversation_trace.py
| 'role': 'assistant', 'text': '', 'status': 'streaming', | ||
| reply_id = str(uuid5(UUID(begin['id']), 'assistant')) | ||
| with self._started_lock: | ||
| self._started[reply_id] = _monotonic() |
There was a problem hiding this comment.
The timer starts before the initial conversation write. With a simulated 2 s write delay, a 250 ms turn was recorded as 2.25 s. Please start timing after the write succeeds and add a regression test with a delayed write.
There was a problem hiding this comment.
Thanks for the precise reproduction, @FayeSpica. Fixed in f92e430e.
The monotonic timer now starts after the initial durable_json() write succeeds, while the finish boundary remains before finish persistence. I added controlled-clock regression cases with 0 ms, 200 ms, and 2,000 ms initial write delays; each records 250 ms of turn time. A separate delayed finish write is also excluded. Tests cover write failure, complete/stopped/interrupted, restart, duplicate begin, and concurrent turns. The English/Chinese timing docs now distinguish persisted startedAt (acceptance timestamp) from the post-write monotonic timing start.
The branch is updated, and all 13/13 GitHub checks pass on f92e430e. Would appreciate another look when you have a chance. Thanks again!
durationMs no longer includes initial conversation persistence latency. Keep the start when a finish write fails so a retry still records a duration. Add delayed-write, failure, duplicate-begin, restart and concurrency tests.
# Conflicts: # apps/api/src/opendirector_api/agent.py # src/canvas/AssistantTracePage.tsx
Summary
Refs #468 (Slice A: per-turn timing only).
Persist authoritative timing metadata for each accepted Agent turn and show the same recorded duration in Chat and the existing conversation-wide Trace page. This is a small, reviewable first slice of the DSH-inspired timing work requested by @FayeSpica; the visual timing overview (Slice B) remains follow-up work.
startedAtandfinishedAt(ISO 8601 UTC) anddurationMs(non-negative integer) on the assistant reply.complete,stopped,interrupted, legacy missing timestamps and post-restart unknown durations without inventing elapsed time.Screenshots
Captured from Chromium with fixture-backed demo data. Chat and Trace show the same persisted turn duration in both UI locales. The sample turn contains no model/tool trace entries, so the Trace detail area correctly displays the empty-trace message.
English UI
简体中文 UI
Timing semantics and limitations
durationMsuses an in-process monotonic measurement. A restart/multi-process handoff may leave onlystartedAtwith an unknown duration; historical turns are not backfilled.turnSecondsunderagent-runs/timing/, with a different boundary. This PR records user-visible turn duration in conversation history. Both can coexist, but their values should not be presented as identical.Validation
test_creation_storage.pyin-place case failed only on the clean-main run and was treated as flaky.npm test, TypeScript, production build, i18n, browser manifest and locale checks passed.assistant_turn_timing.mjspassed;assistant_sessions.mjspassed three consecutive runs on this branch;trace_original_export.mjspassed, preserving [feat] agent: download original conversation traces as a ZIP archive (#421) #422's ZIP export.0f55fa0608d776422510f4de30ce65a185dccd16: all seven Release checks passed; DSH plugin checks and CodeQL also succeeded.Current PR HEAD:
0f55fa0608d776422510f4de30ce65a185dccd16.Parallel development / merge notes
agent.pyand may require retaining both import blocks during integration. A trial integration found conflicting imports and a fake-clock test interaction; the latter was addressed by isolating the monkeypatch target.Out of scope
Slice B DSH-inspired visual overview, trace export, TTFA/TTC benchmarking, new tool-level instrumentation, Job durations, performance optimization, and execution semantics changes.
Review focus
Please review the admission/terminal timing boundaries, cancellation and restart cases, compatibility with #469 and in-flight conversation lifecycle PRs, and the presentation of stopped/interrupted replies.
The PR is currently Ready for Review; CI has passed on the current head.