Sync upstream updates: MCP skills and AI tool input streaming

Merged
BI
21m ago
+3939-193

Laravel Updates

  • laravel/mcp PR 410 — Add support for the MCP Skills extension (io.modelcontextprotocol/skills), including Skill, DirectorySkill, SkillResource, skills/list and skills/get methods, resources/list and resources/read integration, make:mcp-skill generator and stubs, dependencies in src/mcp/composer.json, and skills documentation.
  • laravel/ai PR 1250 — Flag failed tool results with is_error: true when mapping messages for Anthropic.
  • laravel/ai PR 1249 — Port Anthropic prompt-cache test verifying the tools cache breakpoint skips deferred tools and consolidate Hypervel's prior deferred-tool test case under it.
  • laravel/ai PR 1251 — Port Anthropic native structured-output tool-choice tests through ToolChoiceAgent while retaining middleware and thinking coverage.
  • laravel/ai PR 1245 — Capture and replay reasoning fields across OpenAI-compatible tool loops and delegate DeepSeek message mapping to the shared chat-completion mapper while keeping DeepSeek's empty reasoning_content fallback.
  • laravel/ai PR 1241 — Port Groq and OpenAI AG-UI tool-result replay mapping tests verifying paired provider call IDs.
  • laravel/ai PR 1239 — Stream tool input as it arrives via ToolInputStart, ToolInputDelta, and ToolInputError events across all text gateways, Anthropic eager input streaming, TextGenerationLoop, AgentUserInteractionProtocol, VercelDataProtocol, and AI SDK docs.
  • laravel/ai PR 1233 — Honor the Strict attribute on Mistral and OpenRouter tools through MapsChatCompletionTools::supportsStrictTools() and update the AI SDK strict-tools documentation.
  • laravel/ai PR 1261 — Update default, cheapest, and smartest text models in config/ai.php and the Anthropic, Azure OpenAI, Bedrock, Gemini, OpenAI, and OpenRouter providers.

Additional Hypervel changes

  • Clone resolved Skill instances in ServerContext::resolveSkills() so auto-singletoned skill classes do not share once() frontmatter caches across calls in the same coroutine, and register Skill::flushState() in AfterEachTestSubscriber for static attribute metadata cleanup.
  • Replace protected TextGenerationLoop::unfinishedToolInputs() with in-place trackUnfinishedToolInput(array &$toolInputs, StreamEvent $event): void to avoid quadratic copy-on-write string copying across streamed tool-input deltas, and document the protected-helper difference in src/ai/README.md.
  • Extend BroadcastBatcher to batch adjacent ToolInputDelta events by invocation and tool ID, keeping ToolCall ordering intact, and update config/ai.php, src/ai/README.md, src/docs/ai-sdk.md, and src/docs/porting-from-laravel.md.
  • Keep Bedrock's synthetic structured_output tool internal during streaming so generateStreamStep() with a schema does not emit ToolInputStart or ToolInputDelta events for it.
  • Keep resultId null in AgentUserInteraction::toolResultFrom() and document why client- or hydrator-assigned AG-UI message IDs are not copied into provider call_id fields when mappers already pair calls and results on toolCallId.
  • Keep Anthropic's synthetic output_structured_data tool internal during streaming without enabling eager_input_streaming on it, preserve explicit eager_input_streaming values in Anthropic provider options with ??= true, drop malformed Anthropic streamed tool inputs regardless of stop reason (preserving signed thinking replay when another valid tool call remains), and strip length-cut-off tool calls and raw replay blocks on cut-off steps across Anthropic, Bedrock, Cohere, Gemini, and OpenAI.
  • Cast unfinished tool-input keys to string in TextGenerationLoop::unfinishedToolInputErrors() for numeric tool IDs, and populate replayBlocksProvider in TextGenerationLoop::buildAssistantMessage() so in-memory messages strip foreign replay blocks across providers.
  • Filter unsupported temperature and topP sampling parameters on Bedrock Claude 4.7+ and 5.x models (and drop topP when temperature is set on compatible Claude models) in BedrockTextGateway::buildConverseParameters().
  • Send x-anthropic-beta: structured-outputs-2025-11-13 by default in CreatesOpenRouterClient::client() (overridable via configured headers) so OpenRouter enforces strict: true on Claude tool definitions.
  • Preserve custom skills/list and skills/get handlers registered in boot() via ??= in Server::detectSkillsCapability(), and reject empty normalized skill slugs in MakeSkillCommand::handle().

Summary by cubic

Syncs upstream Laravel AI and MCP updates. MCP servers now support the Skills extension (io.modelcontextprotocol/skills), and AI streams publish tool input fragments as they arrive instead of only when a tool's arguments complete.

New Features

  • Adds Skill, DirectorySkill, and SkillResource, plus skills/list and skills/get methods, resource integration, and a make:mcp-skill generator.
  • Adds ToolInputStart, ToolInputDelta, and ToolInputError stream events across all text gateways, Anthropic eager_input_streaming, and AG-UI/Vercel Data mappings.

Behavior Changes

  • Failed Anthropic tool results are flagged is_error: true, and reasoning fields replay under the provider's original field in OpenAI-compatible tool loops.
  • Malformed Anthropic tool inputs are dropped regardless of stop reason, so the stream reports ToolInputError instead of invoking the tool; remaining valid tool calls keep their reasoning replay.
  • DeepSeek now delegates message mapping to the shared OpenAI-compatible mapper, keeping its empty reasoning_content fallback.
  • The Strict attribute is honored on Mistral and OpenRouter tools; default provider model names are updated.
  • Skill instances are cloned per request so auto-singletoned classes don't share once() frontmatter caches, and unfinished tool inputs are tracked in place to avoid quadratic string copying across streamed deltas.

[!NOTE]

Add MCP skills extension and AI tool-input streaming across providers

  • Adds MCP skills: a Skill base class, ServerContext resolution, skills/list and skills/get JSON-RPC methods, and a make:mcp-skill generator command in MakeSkillCommand.php. Registered skills appear as resources with their SKILL.md and bundled files.
  • Adds tool-input streaming for most providers (Anthropic, OpenAI, OpenAI-compatible, Gemini, Bedrock, Cohere, xAI, DeepSeek). A shared StreamsToolInput.php concern emits start and delta events as tool arguments arrive, before the completed tool call.
  • TextGenerationLoop.php emits a ToolInputError when a streamed tool input never completes, and tool input cut off by the length limit is dropped from tool calls and replay blocks.
  • AG-UI and Vercel Data protocol mappers, plus BroadcastBatcher.php, now handle tool-input events; adjacent deltas from the same tool are batched.
  • Also fixes Anthropic failed tool results to be marked is_error, enables strict tools for Mistral and OpenRouter, drops unsupported Bedrock sampling parameters, and changes the default Azure OpenAI deployment to gpt-6.2-sol.
  • Behavioral Change: Anthropic streamed requests enable eager input streaming for typed tools by default (BuildsTextRequests.php), and requests omit topP for supported Claude models when temperature is set (BedrockTextGateway.php).

Macroscope summarized 13c33f7.

Summary by CodeRabbit

  • New Features
    • MCP servers can now expose reusable Skills, with discovery, retrieval, resource access, and a command to generate skill files.
    • AI providers stream tool inputs as they arrive, with incomplete inputs reported as errors rather than executed.
    • Strict tool definitions are supported by Mistral and OpenRouter; failed Anthropic tool results are identified as errors.
  • Improvements
    • Broadcasts batch adjacent tool-input deltas alongside text and reasoning.
    • Updated default AI models across several providers; configured model overrides remain in effect.
  • Documentation
    • Added guidance for MCP Skills and streamed tool inputs.