Support model-specific function description prefixes (#51930)

## What changed

Add `functions_namespace_functions_description_prefixes` to model tool messages, keyed by unqualified tool name. Prepend this guidance to descriptions in the `functions` namespace across direct declarations, Code Mode documentation, and tool-search results, including custom tools.

Trim prefixes, ignore empty values and unavailable functions, and enforce a combined 256-byte UTF-8 limit including separators for reachable tools. Keep overrides local to each step, preserve search ranking text, and retain runtime caches for unaffected tools.

## Testing

Extend coverage for direct and indirect descriptions, clearing prefixes when switching models, namespace scoping for deferred dynamic tools, and tool-search cache reuse and reset.

GitOrigin-RevId: f434e37cec010764fe3e09fb12c339e933b3c21c
This commit is contained in:
tongzhou wang
2026-10-08 03:20:54 +00:00
committed by copyberry
parent 82e70121f8
commit e974aad3b1
15 changed files with 527 additions and 134 deletions
+3 -1
View File
@@ -139,7 +139,9 @@ impl ToolCallRuntime {
.record_tool_call(&call, &source, &step_context);
let router = &step_context.tool_router;
let supports_parallel = router.tool_supports_parallel(&call);
let tool_runtime = router.tool_runtime(&call.tool_name);
let tool_runtime = router
.registered_tool(&call.tool_name)
.map(|tool| Arc::clone(&tool.runtime));
let finishes_on_cancellation = tool_runtime
.as_ref()
.is_some_and(|runtime| runtime.finishes_on_cancellation());