llm: add dynamic tool loading (DTL) — Kimi system-tools + Anthropic tool-reference
Nightly Build / build (push) Successful in 6m51s
Nightly Build / build (push) Successful in 6m51s
Replace the old session_mcp_grants/stack_mcp_grants table pair with
a single activated_tools table that anchors each activation at the
assistant message_id that triggered it. The durable write moves from
the activate_tools tool itself to the round loop (handle_tool_call),
which has the message_id the DTL serializer positions injected tool
blocks against.
Introduce DtlMode (None / AnthropicToolReference / KimiSystemTools),
resolved per model from capabilities (opt-in via tool_search)
combined with the provider's dtl_format(). The message builder inserts
Kimi system {tools} blocks at the activation position, or emits
Anthropic tool_reference markers on the tool result. The tool-def
surface (all_tool_defs) switches shape: Anthropic declares everything
deferred; Kimi omits activated tools from the top-level array (system
takes over); None keeps the old grant-set logic.
Anthropic client: accept structured system arrays (cache_control on
the static block when DTL is active), carry defer_loading through
conversion, emit tool_reference blocks on result messages. Prompt
caching enabled exactly when DTL is active (anthropic provider).
MCP server list in the prompt is now a static catalogue (not split
Available/Active) — the split invalidated the cache on every activation.
Groundwork for providers.yaml dtl: key; Moonshot/Kimi providers wired
with kimi_system_tools and the k3* enrich now adds tool_search.
Compactor re-anchors activations whose message was compacted away.
This commit is contained in:
@@ -183,6 +183,15 @@ pub trait ApiProvider: Send + Sync {
|
||||
None
|
||||
}
|
||||
|
||||
/// The dynamic-tool-loading (DTL) serialization format this provider's models
|
||||
/// speak, e.g. `"anthropic_tool_reference"` or `"kimi_system_tools"`. Applied
|
||||
/// only to a model that opts in via the `tool_search` capability. `None` = no
|
||||
/// DTL (activated tools ride in the top-level `tools`). Returned as a string so
|
||||
/// core-api needs no dependency on the engine's `DtlMode` — the caller parses it.
|
||||
fn dtl_format(&self) -> Option<&str> {
|
||||
None
|
||||
}
|
||||
|
||||
async fn llm_model_info(
|
||||
&self,
|
||||
_record: &LlmProviderRecord,
|
||||
|
||||
Reference in New Issue
Block a user