MCP tool-use execution loop for autonomous agent runs

Autonomous agents with MCP tools now run a bounded tool-use loop: the model may
call tools (executed via the gateway, results fed back) until it returns a final
answer. Gated/DraftOnly agents get the tool catalog as data but never auto-call —
a human-in-the-loop agent never autonomously reaches an external tool.

Extends IModelClient with tool definitions and a tool-use conversation, adds the
OpenAI-compatible tool serialization/parsing plus a deterministic "tooluse" stub
client, and records every tool call in the run trace.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-15 15:20:48 +03:30
parent a9d4d691f0
commit c8d9af6191
5 changed files with 285 additions and 16 deletions
@@ -38,6 +38,7 @@ public sealed class IntegrationsModule : IModule
// Model clients: a router over per-provider adapters.
services.AddSingleton<StubModelClient>();
services.AddSingleton<ToolUseStubModelClient>();
services.AddHttpClient<OpenAiCompatibleModelClient>();
services.AddScoped<IModelClient, ModelClientRouter>();