Skip to content

feat: preserve additional_tools input items verbatim and surface them in the tools UI - #5103

Merged
akshaydeo merged 2 commits into
devfrom
07-10-feat_adds_addition_tools_message_type_support
Jul 12, 2026
Merged

feat: preserve additional_tools input items verbatim and surface them in the tools UI#5103
akshaydeo merged 2 commits into
devfrom
07-10-feat_adds_addition_tools_message_type_support

Conversation

@Pratham-Mishra04

Copy link
Copy Markdown
Collaborator

Summary

Codex code-mode models (e.g. gpt-5.6-sol) send an additional_tools input item containing tool definitions with per-entry type discriminators (custom, function, namespace). Previously, Bifrost's typed schema would decode these through the mcp_list_tools shape, stripping every tools[].type field and causing OpenAI to reject the forwarded request with "Missing required parameter: 'input[0].tools[0].type'". This PR extends the verbatim round-trip preservation already in place for tool_search_call/tool_search_output to also cover additional_tools items, and surfaces those tools in the UI alongside top-level tool declarations.

Changes

  • Added ResponsesMessageTypeAdditionalTools ("additional_tools") to the set of item types that Bifrost preserves verbatim (rawPreserved, formerly rawToolSearch), preventing the typed decoder from mangling nested tool entries.
  • Renamed rawToolSearchrawPreserved and isToolSearchItemisRawPreservedItem to reflect that the mechanism now covers multiple item types.
  • Added "tool_search_call", "tool_search_output", and "additional_tools" to the TypeScript ResponsesMessageType union.
  • In the log detail UI, tools declared via additional_tools input items are now merged with top-level params.tools for display. Namespace-grouped tools are expanded into their callable children (namespace.tool naming). The Tools tab badge, hero stat, and tools panel all reflect the combined count and source breakdown.
  • Added a flattenDeclaredTools helper that expands namespace-type tool entries into individually callable children for display purposes.
  • Added TestResponsesInputRoundTripsAdditionalToolsItems and TestResponsesMessagePreservesAdditionalTools to cover the round-trip behavior, including verifying that a reused receiver does not leak preserved bytes into a subsequent decode.

Type of change

  • Bug fix
  • Feature

Affected areas

  • Core (Go)
  • Providers/Integrations
  • UI (React)

How to test

# Core
go test ./core/schemas/... ./core/providers/openai/...

# UI
cd ui
pnpm i
pnpm build

To reproduce the original failure, send a Responses API request for a code-mode model that includes an additional_tools input item with custom, function, and namespace-typed tool entries and confirm OpenAI no longer rejects with a missing type parameter error.

Breaking changes

  • No

Related issues

Fixes the "Missing required parameter: 'input[0].tools[0].type'" rejection when proxying codex code-mode model requests.

Security considerations

No auth, secrets, or PII implications. The change only affects how specific input item types are serialized when forwarded to OpenAI.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

@CLAassistant

CLAassistant commented Jul 10, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ Pratham-Mishra04
❌ akshaydeo
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b5960edf-03c4-47ae-8113-f28baf7cf05e

📥 Commits

Reviewing files that changed from the base of the PR and between 234faaa and 41f8736.

📒 Files selected for processing (5)
  • core/providers/openai/tool_search_roundtrip_test.go
  • core/schemas/responses.go
  • core/schemas/responses_test.go
  • ui/app/workspace/logs/sheets/logDetailView.tsx
  • ui/lib/types/logs.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • ui/lib/types/logs.ts
  • core/schemas/responses_test.go
  • core/providers/openai/tool_search_roundtrip_test.go
  • ui/app/workspace/logs/sheets/logDetailView.tsx
  • core/schemas/responses.go

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added support for displaying tools declared via additional tool definitions, including nested namespaces.
    • Tool counts, badges, previews, and details now include all available callable tools, with a clear breakdown when namespaces expand and an empty-state when none are declared.
    • Added support for additional tool-related response message types in logs.
  • Bug Fixes

    • Preserved additional tool declarations and nested metadata during request/response round-trips, and prevented this data from leaking into later unrelated messages.
    • Correctly classifies tool search output as tool content.

Walkthrough

The PR preserves OpenAI Responses additional_tools items through JSON round trips, adds backend coverage for nested tools and receiver reuse, and updates log detail views to combine and expand these tools for counts, metadata, and rendering.

Changes

Additional tools support

Layer / File(s) Summary
Responses additional_tools preservation
core/schemas/responses.go, core/schemas/responses_test.go
ResponsesMessage now preserves additional_tools, tool_search_call, and tool_search_output payloads verbatim, clears preserved state on reuse, and tests exact round trips without leakage.
Additional tools round-trip validation
core/providers/openai/tool_search_roundtrip_test.go
Round-trip coverage verifies nested tool types, function parameters, namespace tools, field isolation, and following user-message serialization.
Expanded tool display in logs
ui/lib/types/logs.ts, ui/app/workspace/logs/sheets/logDetailView.tsx
Log views combine input-item tools with configured tools, expand namespaces, update counts and metadata, render tool details, and show an explicit empty-tools state.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ResponsesInput
  participant ResponsesMessage
  participant LogDetailView
  ResponsesInput->>ResponsesMessage: decode additional_tools payload
  ResponsesMessage-->>ResponsesInput: preserve and re-emit raw JSON
  ResponsesInput->>LogDetailView: provide responses_input_history
  LogDetailView->>LogDetailView: combine and expand declared tools
  LogDetailView-->>LogDetailView: render counts, metadata, and tool details
Loading

Possibly related PRs

Suggested reviewers: akshaydeo, danpiths, roroghost17, TejasGhatte

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: preserving additional_tools and exposing them in the UI.
Description check ✅ Passed The description follows the template closely and covers summary, changes, testing, impacts, security, and checklist; screenshots are the only notable omission.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 07-10-feat_adds_addition_tools_message_type_support

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


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

@coderabbitai
coderabbitai Bot requested a review from roroghost17 July 10, 2026 16:29
@greptile-apps

greptile-apps Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
core/schemas/responses.go Adds additional_tools to the raw-preserved Responses item path and keeps the decoder reset behavior.
core/schemas/responses_test.go Adds coverage for byte-identical additional_tools round-tripping and stale preserved-byte cleanup.
core/providers/openai/tool_search_roundtrip_test.go Adds OpenAI request input coverage for nested additional_tools declarations.
ui/app/workspace/logs/sheets/logDetailView.tsx Merges declared tools from request params and Responses input history, expands namespaces, and renders surfaced tool items as tool messages.
ui/lib/types/logs.ts Extends the Responses item type union with tool-search and additional_tools item types.

Reviews (4): Last reviewed commit: "Merge branch 'dev' into 07-10-feat_adds_..." | Re-trigger Greptile

Comment thread ui/app/workspace/logs/sheets/logDetailView.tsx Outdated
Comment thread ui/lib/types/logs.ts

Copy link
Copy Markdown
Collaborator Author

@coderabbitai full-review

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

@Pratham-Mishra04 Sure, I'll perform a full review of all the changes in this PR.

✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
ui/app/workspace/logs/sheets/logDetailView.tsx (1)

2288-2288: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Array index used as list key for declaredTools.map.

declaredTools is now a runtime-composed array (top-level tools + flattened namespace/input-declared tools), so index-based keys are more likely to cause incorrect reconciliation than with a static log.params.tools array (e.g. if a namespace's nested tool count changes across renders/logs). Consider keying by a more stable identifier such as `${tool?.function?.name ?? tool?.name ?? "tool"}-${i}`.

As per coding guidelines: "Always use stable, unique keys in lists; never use array index as key (unless unavoidable)."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui/app/workspace/logs/sheets/logDetailView.tsx` at line 2288, Replace the
index-based key in the declaredTools.map render with a stable tool-derived key,
using the function name or tool name and retaining the index only as a
uniqueness fallback, such as `${tool?.function?.name ?? tool?.name ??
"tool"}-${i}`.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ui/app/workspace/logs/sheets/logDetailView.tsx`:
- Around line 633-646: Deduplicate tool declarations before building the
rendered tools list and badge count. Update the logic around
inputDeclaredToolEntries, flattenDeclaredTools, and declaredTools to merge
top-level and historical additional_tools using tool identity with
last-write-wins semantics, so repeated declarations represent only the final
effective tool set before JSON serialization.

---

Nitpick comments:
In `@ui/app/workspace/logs/sheets/logDetailView.tsx`:
- Line 2288: Replace the index-based key in the declaredTools.map render with a
stable tool-derived key, using the function name or tool name and retaining the
index only as a uniqueness fallback, such as `${tool?.function?.name ??
tool?.name ?? "tool"}-${i}`.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9f622528-5a1e-4917-82e4-da865f0f6c13

📥 Commits

Reviewing files that changed from the base of the PR and between e0d2ac1 and 7e341a6.

📒 Files selected for processing (5)
  • core/providers/openai/tool_search_roundtrip_test.go
  • core/schemas/responses.go
  • core/schemas/responses_test.go
  • ui/app/workspace/logs/sheets/logDetailView.tsx
  • ui/lib/types/logs.ts

Comment thread ui/app/workspace/logs/sheets/logDetailView.tsx
@coderabbitai
coderabbitai Bot requested a review from TejasGhatte July 10, 2026 16:36

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
ui/app/workspace/logs/sheets/logDetailView.tsx (1)

264-271: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use a typed tool-declaration union instead of any[].

The new helper and caller erase type checking for namespace and callable tool fields. Define a narrow tool union in ui/lib/types/logs.ts, retaining unknown provider-specific fields as unknown.

As per coding guidelines, avoid any in TypeScript unless it is unavoidable.

Also applies to: 636-640

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui/app/workspace/logs/sheets/logDetailView.tsx` around lines 264 - 271,
Replace the any-based declarations in flattenDeclaredTools and its caller with a
typed tool-declaration union defined in ui/lib/types/logs.ts, covering namespace
and callable tools while preserving provider-specific fields as unknown. Update
the helper and related usage to use this type, including safe access and mapping
of name/tools, without introducing any.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@ui/app/workspace/logs/sheets/logDetailView.tsx`:
- Around line 264-271: Replace the any-based declarations in
flattenDeclaredTools and its caller with a typed tool-declaration union defined
in ui/lib/types/logs.ts, covering namespace and callable tools while preserving
provider-specific fields as unknown. Update the helper and related usage to use
this type, including safe access and mapping of name/tools, without introducing
any.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 99695cbd-cf38-4f4e-a6f3-de0fd7c99ad9

📥 Commits

Reviewing files that changed from the base of the PR and between e0d2ac1 and 7e341a6.

📒 Files selected for processing (5)
  • core/providers/openai/tool_search_roundtrip_test.go
  • core/schemas/responses.go
  • core/schemas/responses_test.go
  • ui/app/workspace/logs/sheets/logDetailView.tsx
  • ui/lib/types/logs.ts

@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 07-10-feat_adds_addition_tools_message_type_support branch from 7e341a6 to 234faaa Compare July 10, 2026 16:51
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 10, 2026
Comment thread ui/app/workspace/logs/sheets/logDetailView.tsx
Comment thread ui/app/workspace/logs/sheets/logDetailView.tsx
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 07-10-feat_adds_addition_tools_message_type_support branch from 234faaa to 41f8736 Compare July 10, 2026 16:59
@akshaydeo
akshaydeo merged commit a3fb95e into dev Jul 12, 2026
12 of 14 checks passed
@akshaydeo
akshaydeo deleted the 07-10-feat_adds_addition_tools_message_type_support branch July 12, 2026 14:24
akshaydeo added a commit that referenced this pull request Jul 14, 2026
Co-authored-by: Akshay Deo <akshay@akshaydeo.com>
Shaik-Sirajuddin added a commit to Shaik-Sirajuddin/bifrost that referenced this pull request Jul 15, 2026
…, gofmt cleanup

Upstream (maximhq#5103, adds addition_tools support) renamed ResponsesMessage's
private rawToolSearch field to rawPreserved when generalizing raw-byte
preservation beyond tool_search. tool_search_openai_native.go (this branch)
predates that rename and still referenced the old name post-rebase.
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.

[Bug]: Codex gpt-5.6-sol additional_tools loses nested tool types on /v1/responses

3 participants