You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(interview-coach): bind grading snapshots to the tool call, not shared state
The user_turn_seq / response_turn_seq guard from 98b31fc only held until the
*next* response started: that overwrote response_turn_seq, the equality became
true again, and a delayed call from the earlier turn was rebound to the newer
transcript. Comparing two mutable globals could never express "this call's
turn" — it only described the pipeline's current position.
Replaced with an immutable per-invocation snapshot. pipecat's
on_function_calls_started fires when the LLM announces its calls, before the
runner executes them and while the originating turn is still current, and each
FunctionCallFromLLM carries a unique tool_call_id. The handler freezes the
answer, question, rubric id and rubric text under that id; the tool consumes
its own entry via params.tool_call_id. Nothing later can rebind it. The store
is capped at MAX_CALL_SNAPSHOTS so a call whose handler never runs cannot leak.
The rubric now comes from the same snapshot as the answer, so a graded turn
cannot be scored against a rubric fetched for a later one.
Note the event dispatches handlers as tasks rather than awaiting them, so the
snapshot is not strictly guaranteed to be recorded before the handler runs. The
fallback is safe by construction: with no snapshot the tool uses the supplied
arguments, which are themselves bound to the invocation — never shared state
that may have moved on.
Verified with the reported sequence — turn 1 call, barge-in to turn 2, next
response starts, then the delayed call runs: the old guard resolved to turn 2's
answer and question, the snapshot stays on turn 1 with its matching rubric.
Normal, missing-snapshot and prompt-injection cases all unchanged.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
0 commit comments