-
Notifications
You must be signed in to change notification settings - Fork 4
feat(events): carry tool outcome (duration/size/error) on ToolCompleted #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -260,12 +260,22 @@ impl<State: Send + Sync, Ctx: Send + Sync> AgentHarness<State, Ctx> { | |
| .capture | ||
| .tool_io | ||
| .then(|| Value::String(result.content.clone())); | ||
| // Outcome fields carried on the event itself (not a side-channel) so | ||
| // journal-backed exporters render duration/size/success without the | ||
| // live run's state. Duration is wall-clock (completion minus start); | ||
| // `error` mirrors `ToolResult::error` (`None` == success). | ||
| let duration_ms = crate::harness::ids::now_ms().saturating_sub(prepared.started_at_ms); | ||
| let output_bytes = result.content.len() as u64; | ||
| let error = result.error.clone(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎. |
||
| let record = ctx.emit(AgentEvent::ToolCompleted { | ||
| call_id: prepared.call_id, | ||
| tool_name: prepared.tool_name, | ||
| started_at_ms: Some(prepared.started_at_ms), | ||
| input: prepared.captured_input, | ||
| output: captured_output, | ||
| duration_ms: Some(duration_ms), | ||
| output_bytes: Some(output_bytes), | ||
| error, | ||
| }); | ||
| status.set_last_event(record.id); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a turn uses the concurrent tool path (multiple tool calls and no tool-wrap middleware),
execute_tools_concurrentlyawaits every future withjoin_allbefore callingfinish_tool_callin call order. Computingduration_mshere therefore measures until fold time, so a fast tool that finished early is reported as running until the slowest sibling completes (and later tools also include earlierafter_toolhooks), which corrupts the journal/Langfuse execution window for parallel tools. Capture the completion timestamp/elapsed duration inside each tool future beforejoin_allreturns instead.Useful? React with 👍 / 👎.