harness: add optional tool_name to ToolDelta (self-labeling streamed tool calls)#34
Conversation
…elf-label
A streaming tool call's name arrives on the call-opening fragment, before its
arguments. `ToolDelta` previously carried only `{call_id, content}`, so a
consumer projecting the stream had no way to label the call until the final
response. Add `ToolDelta::tool_name: Option<String>`:
- The OpenAI SSE parser surfaces the captured function name on the tool-call
delta.
- `StreamAccumulator` records the first non-empty name per call id and stamps it
onto the reconstructed `ToolCall`, so a stream-only response (no authoritative
`Completed`) still names its tool calls.
Backward-compatible: `#[serde(default, skip_serializing_if = "Option::is_none")]`,
so existing payloads round-trip unchanged. New focused accumulator test.
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 43 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 27aae7ddf8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Surface the tool name (captured into `slot.name` from | ||
| // the call-opening fragment) so consumers can label the | ||
| // call as it streams; the accumulator keeps the first. | ||
| tool_name: Some(slot.name.clone()).filter(|n| !n.is_empty()), |
There was a problem hiding this comment.
Emit the tool name when the call opens
Because this is populated from the cached slot.name only inside the non-empty-arguments branch, an OpenAI opening fragment such as {name: "lookup", arguments: ""} emits no start/name delta at all, and then every later split argument fragment carries Some("lookup") because the slot name remains cached. That contradicts the new ToolDelta contract that the name labels the call-opening delta and later argument fragments leave it None; consumers using Some(tool_name) as the streamed start marker will miss zero-argument/name-only openings and can emit duplicate starts for chunked arguments. Emit a delta when a new non-empty name is observed and only mark the name once per call.
Useful? React with 👍 / 👎.
Summary
A streaming tool call's name arrives on the call-opening fragment, before its arguments.
ToolDeltacarried only{call_id, content}, so a consumer projecting the stream couldn't label the call until the final response. This addsToolDelta::tool_name: Option<String>.StreamAccumulatorrecords the first non-empty name per call id and stamps it onto the reconstructedToolCall, so a stream-only response (no authoritativeCompleted) still names its tool calls.Backward-compatible:
#[serde(default, skip_serializing_if = "Option::is_none")]— existing payloads round-trip unchanged.Tests
finish_names_reconstructed_tool_call_from_the_call_opening_delta_name); existing model + e2e contract tests updated for the new field and green.Motivation
Unblocks the OpenHuman inference migration (tinyhumansai/openhuman#4613): lets the streamed tool-call start marker ride the native crate stream so the host's out-of-band forwarder can be deleted.