Skip to content

harness: add optional tool_name to ToolDelta (self-labeling streamed tool calls)#34

Merged
senamakel merged 1 commit into
mainfrom
feat/tooldelta-tool-name-g2
Jul 7, 2026
Merged

harness: add optional tool_name to ToolDelta (self-labeling streamed tool calls)#34
senamakel merged 1 commit into
mainfrom
feat/tooldelta-tool-name-g2

Conversation

@senamakel

Copy link
Copy Markdown
Member

Summary

A streaming tool call's name arrives on the call-opening fragment, before its arguments. ToolDelta carried only {call_id, content}, so a consumer projecting the stream couldn't label the call until the final response. This adds ToolDelta::tool_name: Option<String>.

  • 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")] — existing payloads round-trip unchanged.

Tests

  • New focused accumulator test (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.

…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.
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 43 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ec748173-ac5b-44f3-9861-aee244759f4e

📥 Commits

Reviewing files that changed from the base of the PR and between 3d9fcfb and 27aae7d.

📒 Files selected for processing (6)
  • src/harness/model/mod.rs
  • src/harness/model/test.rs
  • src/harness/providers/openai/sse.rs
  • src/harness/tool/types.rs
  • tests/e2e_harness_provider_contracts.rs
  • tests/e2e_middleware_parser_contracts.rs

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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()),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant