0xPlaygrounds / 0xPlaygrounds/rig

feat: support provider-hosted tools in AgentBuilder end-to-end

Aperta
#1,890 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
8.6k
Fork
959
Merge medio
4h 32m
PR unite (30g)
117

Descrizione

- [x] I have looked for existing issues (including closed) about this

## Feature Request

Add first-class support for provider-hosted tools in `AgentBuilder`, end-to-end from agent configuration through provider serialization.

### Motivation

Some LLM providers expose built-in tools (e.g. web search, code interpreter, file search) that sit alongside function-calling tools in the `tools` array of Chat Completions requests. These are *provider-hosted* — the provider executes them server-side and injects results directly into the LLM context, without requiring the client to implement execution logic.

Currently, `rig-core` has the `ProviderToolDefinition` type and `CompletionRequestBuilder::provider_tools()`, but the feature is incomplete:

- No provider actually consumes provider tools
- `AgentBuilder` has no equivalent method
- Provider serialization using `#[serde(flatten)]` on `additional_params` produces duplicate `"tools"` keys when both function tools and provider tools coexist, causing API rejections

### Proposal

1. **`AgentBuilder`**: expose `provider_tool()` / `provider_tools()` methods, mirroring `CompletionRequestBuilder`

2. **Agent runtime** (`agent/completion.rs`): pass provider tools alongside function tools when building the completion request (currently only function tools are set via `completion_request.tools(tooldefs)`)

3. **Provider layer**: fix serialization so function tools and provider tools are merged into a single `"tools"` array instead of producing duplicate keys via `#[serde(flatten)]` on `additional_params`. One approach: in `TryFrom`, merge provider tools from `additional_params` into the `tools` field, then strip them from `additional_params`.

### Alternatives

1. **Use `additional_params` directly** — tested and failed. API rejects duplicate `"tools"` keys produced by serde flatten.

2. **Bypass AgentBuilder, use `CompletionRequestBuilder` directly** — loses ReAct loop, ToolServer, PromptHook, history management, and error retry logic. Essentially requires rewriting the agent runtime.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start by examining the `AgentBuilder` struct and its methods in the codebase, then look at `agent/completion.rs` to see how the completion request is built. Review the `ProviderToolDefinition` type and `CompletionRequestBuilder::provider_tools()`. The fix involves modifying serialization in the provider layer to merge tools arrays, likely in the `TryFrom` implementation. Run existing tests related to agent building and provider serialization to ensure changes don't break functionality.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
rust
Ambito
ai-infra-agents
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Specificata chiaramente
Idoneità per principianti
55/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.