feat(v1): progress hook for live traces - #2573
Draft
faresobeid wants to merge 1 commit into
Draft
Conversation
Agent.run / Agent.interaction (and Rollout) take on_progress; the interception server notifies it from record_call, once per recorded exchange, after the turn it committed. A raising hook is logged and swallowed, never the rollout's failure.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Agent.run(...),Agent.interaction(...)andRollout(...)takeon_progress: Callable[[Trace], None] | None. The interception server invokes it fromrecord_call— the one seam every recorded exchange passes through, after the turn it committed — so the hook sees the live trace each time it gains aModelCall(and the nodes of that turn). A hook that raises is logged atWARNINGand swallowed; a consumer bug never fails a rollout.None(the default) changes nothing. Callers debounce.Why
on_tracehands out the trace object at mint, but nothing signals when it grows: a live consumer has to poll. In the data-flywheel pipeline (a task factory onverifiers.v1+ the rho harness, ~90 concurrent rollouts), a 2-hour rollout is invisible until it closes — its model calls and turns can only be inspected after the fact, so stuck or runaway rollouts are noticed late.Validation
tests/v1/test_trace.py::test_on_progress_observes_live_trace— offline: a loopback chat-completions upstream, an in-process harness that makes 3 model calls through the real interception server,agent.run(task, on_progress=...). Asserts the hook fires once per call with the live (is) trace,len(trace.calls)grows 1, 2, 3, and that a hook raising every time still leavestrace.okwith no errors.uv run pytest tests/v1 -m "not e2e": 87 passed.uv run ruff check,uv run pre-commit run --all-files: clean.Note
Add
on_progresslive-trace callback toAgent.run,Rollout, andRolloutSessionon_progressparameter threaded throughAgent.run,_run_once,interaction,_EpisodeAgent,Rollout.__init__, andRolloutSessionso callers can observe the liveTraceafter each recorded model call.InterceptionServercall-recording handler now invokesRolloutSession.progressafter trace content is committed, delivering the current trace to the callback.RolloutSession.progressreturns immediately when no callback is set and logs ordinaryExceptionsubclasses without re-raising, so a faulty consumer cannot fail the rollout.ProbeHarnessto assert three calls, a shared live trace, callback counts of one through three, and rollout success despite aRuntimeErrorraised from the consumer.BaseExceptionerrors are swallowed and logged; callers relying on exceptions propagating out ofAgent.runwill no longer see them.Macroscope summarized e19af4d.