Repository navigation
Tags
Tags
feat(ai): limit GLM tool-calling turns to 10 (#17043) `LanguageModelSession` keeps calling tools for as long as the model returns function calls, so with `.required`, or when Gemini repeats a function call, the number of requests was unbounded. Limit each prompt to 10 tool-calling turns, matching the Android and Web SDKs. After 10 turns, the next request keeps the function declarations but uses function calling mode `NONE` so that Gemini gives a final response. `LanguageModelSession` also runs every tool call that names one of its tools, even with `.disallowed` or for a tool that isn't enabled for the request. Throw `GeminiLanguageModel.Error.invalidResponse` instead of passing on a function call when function calling is disabled (the `disallowed` mode, no enabled tools, or the turn limit) or the tool isn't enabled, and when Gemini stops with the `UNEXPECTED_TOOL_CALL` or `MALFORMED_FUNCTION_CALL` finish reason. Check every function call in a chunk before streaming any of the chunk's parts. When a request enables no tools but the transcript has tool calls, declare the tools from the most recent instructions entry that lists tools with mode `NONE`, skipping any tool whose schema can't be translated. Also: - Count turns from the transcript, so that the executor stays stateless and each prompt starts a new count. - Reject function calls with a missing or empty name. - Document the limit, the transcript reversion on errors, and the `historyTransform(_:)` caveat on `capabilities`, and fix Apple documentation links. - Add unit tests and an integration test.
feat(ai): limit GLM tool-calling turns to 10 (#17043) `LanguageModelSession` keeps calling tools for as long as the model returns function calls, so with `.required`, or when Gemini repeats a function call, the number of requests was unbounded. Limit each prompt to 10 tool-calling turns, matching the Android and Web SDKs. After 10 turns, the next request keeps the function declarations but uses function calling mode `NONE` so that Gemini gives a final response. `LanguageModelSession` also runs every tool call that names one of its tools, even with `.disallowed` or for a tool that isn't enabled for the request. Throw `GeminiLanguageModel.Error.invalidResponse` instead of passing on a function call when function calling is disabled (the `disallowed` mode, no enabled tools, or the turn limit) or the tool isn't enabled, and when Gemini stops with the `UNEXPECTED_TOOL_CALL` or `MALFORMED_FUNCTION_CALL` finish reason. Check every function call in a chunk before streaming any of the chunk's parts. When a request enables no tools but the transcript has tool calls, declare the tools from the most recent instructions entry that lists tools with mode `NONE`, skipping any tool whose schema can't be translated. Also: - Count turns from the transcript, so that the executor stays stateless and each prompt starts a new count. - Reject function calls with a missing or empty name. - Document the limit, the transcript reversion on errors, and the `historyTransform(_:)` caveat on `capabilities`, and fix Apple documentation links. - Add unit tests and an integration test.
feat(ai): limit GLM tool-calling turns to 10 (#17043) `LanguageModelSession` keeps calling tools for as long as the model returns function calls, so with `.required`, or when Gemini repeats a function call, the number of requests was unbounded. Limit each prompt to 10 tool-calling turns, matching the Android and Web SDKs. After 10 turns, the next request keeps the function declarations but uses function calling mode `NONE` so that Gemini gives a final response. `LanguageModelSession` also runs every tool call that names one of its tools, even with `.disallowed` or for a tool that isn't enabled for the request. Throw `GeminiLanguageModel.Error.invalidResponse` instead of passing on a function call when function calling is disabled (the `disallowed` mode, no enabled tools, or the turn limit) or the tool isn't enabled, and when Gemini stops with the `UNEXPECTED_TOOL_CALL` or `MALFORMED_FUNCTION_CALL` finish reason. Check every function call in a chunk before streaming any of the chunk's parts. When a request enables no tools but the transcript has tool calls, declare the tools from the most recent instructions entry that lists tools with mode `NONE`, skipping any tool whose schema can't be translated. Also: - Count turns from the transcript, so that the executor stays stateless and each prompt starts a new count. - Reject function calls with a missing or empty name. - Document the limit, the transcript reversion on errors, and the `historyTransform(_:)` caveat on `capabilities`, and fix Apple documentation links. - Add unit tests and an integration test.
PreviousNext