Sync upstream updates: MCP skills and AI tool input streaming
Merged
BI
11m ago+3939+3939+0123456789012345678901234567890123456789-193-193-012345678901234567890123456789
Laravel Updates
- laravel/mcp#410 — Add support for the MCP Skills extension (
io.modelcontextprotocol/skills), includingSkill,DirectorySkill,SkillResource,skills/listandskills/getmethods,resources/listandresources/readintegration,make:mcp-skillgenerator and stubs, dependencies insrc/mcp/composer.json, and skills documentation. - laravel/ai#1250 — Flag failed tool results with
is_error: truewhen mapping messages for Anthropic. - laravel/ai#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#1251 — Port Anthropic native structured-output tool-choice tests through
ToolChoiceAgentwhile retaining middleware and thinking coverage. - laravel/ai#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_contentfallback. - laravel/ai#1241 — Port Groq and OpenAI AG-UI tool-result replay mapping tests verifying paired provider call IDs.
- laravel/ai#1239 — Stream tool input as it arrives via
ToolInputStart,ToolInputDelta, andToolInputErrorevents across all text gateways, Anthropic eager input streaming,TextGenerationLoop,AgentUserInteractionProtocol,VercelDataProtocol, and AI SDK docs. - laravel/ai#1233 — Honor the
Strictattribute on Mistral and OpenRouter tools throughMapsChatCompletionTools::supportsStrictTools()and update the AI SDK strict-tools documentation. - laravel/ai#1261 — Update default, cheapest, and smartest text models in
config/ai.phpand the Anthropic, Azure OpenAI, Bedrock, Gemini, OpenAI, and OpenRouter providers.
Additional Hypervel changes
- Clone resolved
Skillinstances inServerContext::resolveSkills()so auto-singletoned skill classes do not shareonce()frontmatter caches across calls in the same coroutine, and registerSkill::flushState()inAfterEachTestSubscriberfor static attribute metadata cleanup. - Replace protected
TextGenerationLoop::unfinishedToolInputs()with in-placetrackUnfinishedToolInput(array &$toolInputs, StreamEvent $event): voidto avoid quadratic copy-on-write string copying across streamed tool-input deltas, and document the protected-helper difference insrc/ai/README.md. - Extend
BroadcastBatcherto batch adjacentToolInputDeltaevents by invocation and tool ID, keepingToolCallordering intact, and updateconfig/ai.php,src/ai/README.md,src/docs/ai-sdk.md, andsrc/docs/porting-from-laravel.md. - Keep Bedrock's synthetic
structured_outputtool internal during streaming sogenerateStreamStep()with a schema does not emitToolInputStartorToolInputDeltaevents for it. - Keep
resultIdnull inAgentUserInteraction::toolResultFrom()and document why client- or hydrator-assigned AG-UI message IDs are not copied into providercall_idfields when mappers already pair calls and results ontoolCallId. - Keep Anthropic's synthetic
output_structured_datatool internal during streaming without enablingeager_input_streamingon it, preserve expliciteager_input_streamingvalues in Anthropic provider options with??= true, drop malformed Anthropic streamed tool inputs regardless of stop reason (preserving signedthinkingreplay 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
stringinTextGenerationLoop::unfinishedToolInputErrors()for numeric tool IDs, and populatereplayBlocksProviderinTextGenerationLoop::buildAssistantMessage()so in-memory messages strip foreign replay blocks across providers. - Filter unsupported
temperatureandtopPsampling parameters on Bedrock Claude 4.7+ and 5.x models (and droptopPwhentemperatureis set on compatible Claude models) inBedrockTextGateway::buildConverseParameters(). - Send
x-anthropic-beta: structured-outputs-2025-11-13by default inCreatesOpenRouterClient::client()(overridable via configuredheaders) so OpenRouter enforcesstrict: trueon Claude tool definitions. - Preserve custom
skills/listandskills/gethandlers registered inboot()via??=inServer::detectSkillsCapability(), and reject empty normalized skill slugs inMakeSkillCommand::handle().
[!NOTE]
Add MCP skills extension and AI tool-input streaming across providers
- Adds the MCP skills feature: a
Skill base class, skills/list and skills/get server methods, skill resources in resource listing, and a make:mcp-skill generator command with published stubs. Skills are declared on Server and resolved through ServerContext::skills(), with support for class names, instances, and directory paths.
- Adds tool-input streaming to all AI gateways via a shared
StreamsToolInput concern. Streams now emit ToolInputStart and ToolInputDelta events as tool-call arguments arrive, and ToolInputError for incomplete inputs. Cut-off tool calls (Length finish reason with incomplete JSON) are not invoked and are excluded from replay blocks.
- Maps the new tool-input events to AG-UI (
TOOL_CALL_START, TOOL_CALL_ARGS, TOOL_CALL_END) and Vercel data protocol parts; BroadcastBatcher batches tool-input deltas with matching invocation and tool IDs.
- Adds strict-tool support for Mistral and OpenRouter (
supportsStrictTools(), plus the x-anthropic-beta structured-outputs header for OpenRouter), is_error flagging on failed Anthropic tool results, eager input streaming for Anthropic, and updated default/smartest model fallbacks across providers.
- Risk: incomplete streamed tool inputs now produce
ToolInputError events and are never invoked — check TextGenerationLoop::trackUnfinishedToolInput() and each gateway's HandlesTextStreaming if consumers rely on cut-off calls being emitted with empty arguments. Bedrock requests drop sampling parameters for incompatible Claude models (Claude 5, 4.7, Fable) in BedrockTextGateway::buildConverseParameters().
Macroscope summarized 13c33f7.
Summary by CodeRabbit
- New Features
- Streamed tool inputs now show arguments as they arrive across supported AI providers. Incomplete inputs are reported as errors rather than invoked.
- Added MCP Skills support, including discovery, retrieval, resource access, and a command to create skills.
- Mistral and OpenRouter now support strict tool definitions.
- Improvements
- Agent broadcasts can batch tool-input deltas.
- Updated default AI models across several providers.
- Failed Anthropic tool results are now marked as errors.
- Reasoning is preserved when replaying compatible-provider conversations.
- Documentation
- Added MCP Skills guidance and updated AI streaming documentation.