diff --git a/pydantic_ai_slim/pydantic_ai/models/groq.py b/pydantic_ai_slim/pydantic_ai/models/groq.py index 881364dcad..9739639e09 100644 --- a/pydantic_ai_slim/pydantic_ai/models/groq.py +++ b/pydantic_ai_slim/pydantic_ai/models/groq.py @@ -7,6 +7,7 @@ from datetime import datetime from typing import Any, Literal, cast, overload +from pydantic import BaseModel, Json, ValidationError from typing_extensions import assert_never from pydantic_ai._output import DEFAULT_OUTPUT_TOOL_NAME, OutputObjectDefinition @@ -50,7 +51,7 @@ ) try: - from groq import NOT_GIVEN, APIStatusError, AsyncGroq, AsyncStream + from groq import NOT_GIVEN, APIError, APIStatusError, AsyncGroq, AsyncStream from groq.types import chat from groq.types.chat.chat_completion_content_part_image_param import ImageURL except ImportError as _import_error: @@ -171,9 +172,24 @@ async def request( model_request_parameters: ModelRequestParameters, ) -> ModelResponse: check_allow_model_requests() - response = await self._completions_create( - messages, False, cast(GroqModelSettings, model_settings or {}), model_request_parameters - ) + try: + response = await self._completions_create( + messages, False, cast(GroqModelSettings, model_settings or {}), model_request_parameters + ) + except ModelHTTPError as e: + if isinstance(e.body, dict): # pragma: no branch + # The Groq SDK tries to be helpful by raising an exception when generated tool arguments don't match the schema, + # but we'd rather handle it ourselves so we can tell the model to retry the tool call. + try: + error = _GroqToolUseFailedError.model_validate(e.body) # pyright: ignore[reportUnknownMemberType] + tool_call_part = ToolCallPart( + tool_name=error.error.failed_generation.name, + args=error.error.failed_generation.arguments, + ) + return ModelResponse(parts=[tool_call_part]) + except ValidationError: + pass + raise model_response = self._process_response(response) return model_response @@ -477,36 +493,52 @@ class GroqStreamedResponse(StreamedResponse): _provider_name: str async def _get_event_iterator(self) -> AsyncIterator[ModelResponseStreamEvent]: - async for chunk in self._response: - self._usage += _map_usage(chunk) - - try: - choice = chunk.choices[0] - except IndexError: - continue - - # Handle the text part of the response - content = choice.delta.content - if content is not None: - maybe_event = self._parts_manager.handle_text_delta( - vendor_part_id='content', - content=content, - thinking_tags=self._model_profile.thinking_tags, - ignore_leading_whitespace=self._model_profile.ignore_streamed_leading_whitespace, - ) - if maybe_event is not None: # pragma: no branch - yield maybe_event - - # Handle the tool calls - for dtc in choice.delta.tool_calls or []: - maybe_event = self._parts_manager.handle_tool_call_delta( - vendor_part_id=dtc.index, - tool_name=dtc.function and dtc.function.name, - args=dtc.function and dtc.function.arguments, - tool_call_id=dtc.id, - ) - if maybe_event is not None: - yield maybe_event + try: + async for chunk in self._response: + self._usage += _map_usage(chunk) + + try: + choice = chunk.choices[0] + except IndexError: + continue + + # Handle the text part of the response + content = choice.delta.content + if content is not None: + maybe_event = self._parts_manager.handle_text_delta( + vendor_part_id='content', + content=content, + thinking_tags=self._model_profile.thinking_tags, + ignore_leading_whitespace=self._model_profile.ignore_streamed_leading_whitespace, + ) + if maybe_event is not None: # pragma: no branch + yield maybe_event + + # Handle the tool calls + for dtc in choice.delta.tool_calls or []: + maybe_event = self._parts_manager.handle_tool_call_delta( + vendor_part_id=dtc.index, + tool_name=dtc.function and dtc.function.name, + args=dtc.function and dtc.function.arguments, + tool_call_id=dtc.id, + ) + if maybe_event is not None: + yield maybe_event + except APIError as e: + if isinstance(e.body, dict): # pragma: no branch + # The Groq SDK tries to be helpful by raising an exception when generated tool arguments don't match the schema, + # but we'd rather handle it ourselves so we can tell the model to retry the tool call + try: + error = _GroqToolUseFailedInnerError.model_validate(e.body) # pyright: ignore[reportUnknownMemberType] + yield self._parts_manager.handle_tool_call_part( + vendor_part_id='tool_use_failed', + tool_name=error.failed_generation.name, + args=error.failed_generation.arguments, + ) + return + except ValidationError as e: # pragma: no cover + pass + raise # pragma: no cover @property def model_name(self) -> GroqModelName: @@ -538,3 +570,31 @@ def _map_usage(completion: chat.ChatCompletionChunk | chat.ChatCompletion) -> us input_tokens=response_usage.prompt_tokens, output_tokens=response_usage.completion_tokens, ) + + +class _GroqToolUseFailedGeneration(BaseModel): + name: str + arguments: dict[str, Any] + + +class _GroqToolUseFailedInnerError(BaseModel): + message: str + type: Literal['invalid_request_error'] + code: Literal['tool_use_failed'] + failed_generation: Json[_GroqToolUseFailedGeneration] + + +class _GroqToolUseFailedError(BaseModel): + # The Groq SDK tries to be helpful by raising an exception when generated tool arguments don't match the schema, + # but we'd rather handle it ourselves so we can tell the model to retry the tool call. + # Example payload from `exception.body`: + # { + # 'error': { + # 'message': "Tool call validation failed: tool call validation failed: parameters for tool get_something_by_name did not match schema: errors: [missing properties: 'name', additionalProperties 'foo' not allowed]", + # 'type': 'invalid_request_error', + # 'code': 'tool_use_failed', + # 'failed_generation': '{"name": "get_something_by_name", "arguments": {\n "foo": "bar"\n}}', + # } + # } + + error: _GroqToolUseFailedInnerError diff --git a/tests/models/cassettes/test_groq/test_tool_regular_error.yaml b/tests/models/cassettes/test_groq/test_tool_regular_error.yaml new file mode 100644 index 0000000000..79906a62a9 --- /dev/null +++ b/tests/models/cassettes/test_groq/test_tool_regular_error.yaml @@ -0,0 +1,98 @@ +interactions: +- request: + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '92' + content-type: + - application/json + host: + - api.groq.com + method: POST + parsed_body: + messages: + - content: hello + role: user + model: non-existent + n: 1 + stream: false + uri: https://api.groq.com/openai/v1/chat/completions + response: + headers: + alt-svc: + - h3=":443"; ma=86400 + cache-control: + - private, max-age=0, no-store, no-cache, must-revalidate + connection: + - keep-alive + content-length: + - '153' + content-type: + - application/json + transfer-encoding: + - chunked + vary: + - Origin + parsed_body: + error: + code: model_not_found + message: The model `non-existent` does not exist or you do not have access to it. + type: invalid_request_error + status: + code: 404 + message: Not Found +- request: + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '92' + content-type: + - application/json + cookie: + - __cf_bm=iezhhe87vg5KFYcM9IscO.LHkV8Rv0iM504X.mfCjyk-1756847105-1.0.1.1-otC4FjCOjx._h6QtwT8RmzJksvvp7AaYmv5_.yVAgRa9R4Aon_.qtG1HP7KVwunhgrIiWaZPQhPwh81YLf3h9rC_loDrBn.TQgDMlZ19B0w + host: + - api.groq.com + method: POST + parsed_body: + messages: + - content: hello + role: user + model: non-existent + n: 1 + stream: false + uri: https://api.groq.com/openai/v1/chat/completions + response: + headers: + alt-svc: + - h3=":443"; ma=86400 + cache-control: + - private, max-age=0, no-store, no-cache, must-revalidate + connection: + - keep-alive + content-length: + - '153' + content-type: + - application/json + transfer-encoding: + - chunked + vary: + - Origin + parsed_body: + error: + code: model_not_found + message: The model `non-existent` does not exist or you do not have access to it. + type: invalid_request_error + status: + code: 404 + message: Not Found +version: 1 diff --git a/tests/models/cassettes/test_groq/test_tool_use_failed_error.yaml b/tests/models/cassettes/test_groq/test_tool_use_failed_error.yaml new file mode 100644 index 0000000000..bfa3ea7c39 --- /dev/null +++ b/tests/models/cassettes/test_groq/test_tool_use_failed_error.yaml @@ -0,0 +1,322 @@ +interactions: +- request: + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '517' + content-type: + - application/json + host: + - api.groq.com + method: POST + parsed_body: + messages: + - content: Be concise. Never use pretty double quotes, just regular ones. + role: system + - content: Please call the "get_something_by_name" tool with non-existent parameters to test error handling + role: user + model: openai/gpt-oss-120b + n: 1 + stream: false + tool_choice: auto + tools: + - function: + description: '' + name: get_something_by_name + parameters: + additionalProperties: false + properties: + name: + type: string + required: + - name + type: object + type: function + uri: https://api.groq.com/openai/v1/chat/completions + response: + headers: + alt-svc: + - h3=":443"; ma=86400 + cache-control: + - private, max-age=0, no-store, no-cache, must-revalidate + connection: + - keep-alive + content-length: + - '401' + content-type: + - application/json + vary: + - Origin + parsed_body: + error: + code: tool_use_failed + failed_generation: |- + {"name": "get_something_by_name", "arguments": { + "invalid_param": "test" + }} + message: 'Tool call validation failed: tool call validation failed: parameters for tool get_something_by_name did + not match schema: errors: [missing properties: ''name'', additionalProperties ''invalid_param'' not allowed]' + type: invalid_request_error + status: + code: 400 + message: Bad Request +- request: + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '1194' + content-type: + - application/json + cookie: + - __cf_bm=WMG3BQS5HkdpU5Z0Li6BHrMf9LpbLVf439yJW6y0o_Y-1756847034-1.0.1.1-QyWCGYlk_BGpqUCXdhczqr0bBq94afUlKTqyv_FDO5ksNzCNdNY5QkKBCi.RoWCRo.oIhWHmFJ3mW_Ab3IyyI3wFCLdQql_yH0EkgoEi31M + host: + - api.groq.com + method: POST + parsed_body: + messages: + - content: Be concise. Never use pretty double quotes, just regular ones. + role: system + - content: Please call the "get_something_by_name" tool with non-existent parameters to test error handling + role: user + - role: assistant + tool_calls: + - function: + arguments: '{"invalid_param":"test"}' + name: get_something_by_name + id: pyd_ai_ad025dbe97d74d7f8693ee8fe14fa558 + type: function + - content: |- + 2 validation errors: [ + { + "type": "missing", + "loc": [ + "name" + ], + "msg": "Field required", + "input": { + "invalid_param": "test" + } + }, + { + "type": "extra_forbidden", + "loc": [ + "invalid_param" + ], + "msg": "Extra inputs are not permitted", + "input": "test" + } + ] + + Fix the errors and try again. + role: tool + tool_call_id: pyd_ai_ad025dbe97d74d7f8693ee8fe14fa558 + model: openai/gpt-oss-120b + n: 1 + stream: false + tool_choice: auto + tools: + - function: + description: '' + name: get_something_by_name + parameters: + additionalProperties: false + properties: + name: + type: string + required: + - name + type: object + type: function + uri: https://api.groq.com/openai/v1/chat/completions + response: + headers: + alt-svc: + - h3=":443"; ma=86400 + cache-control: + - private, max-age=0, no-store, no-cache, must-revalidate + connection: + - keep-alive + content-length: + - '827' + content-type: + - application/json + transfer-encoding: + - chunked + vary: + - Origin + parsed_body: + choices: + - finish_reason: tool_calls + index: 0 + logprobs: null + message: + reasoning: 'We need to call with correct param name: name. Provide a non-existent name perhaps "nonexistent".' + role: assistant + tool_calls: + - function: + arguments: '{"name":"nonexistent"}' + name: get_something_by_name + id: fc_c8fd1e7c-0e6b-4a28-8ef2-516c38aa9ba8 + type: function + created: 1756847034 + id: chatcmpl-01583e50-828f-4759-82e2-08b35493ebe6 + model: openai/gpt-oss-120b + object: chat.completion + service_tier: on_demand + system_fingerprint: fp_213abb2467 + usage: + completion_time: 0.097360195 + completion_tokens: 49 + prompt_time: 0.01243387 + prompt_tokens: 283 + queue_time: 0.245412094 + total_time: 0.109794065 + total_tokens: 332 + usage_breakdown: null + x_groq: + id: req_01k463wm1xesw9bd2z9mvdrt70 + status: + code: 200 + message: OK +- request: + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '1500' + content-type: + - application/json + cookie: + - __cf_bm=WMG3BQS5HkdpU5Z0Li6BHrMf9LpbLVf439yJW6y0o_Y-1756847034-1.0.1.1-QyWCGYlk_BGpqUCXdhczqr0bBq94afUlKTqyv_FDO5ksNzCNdNY5QkKBCi.RoWCRo.oIhWHmFJ3mW_Ab3IyyI3wFCLdQql_yH0EkgoEi31M + host: + - api.groq.com + method: POST + parsed_body: + messages: + - content: Be concise. Never use pretty double quotes, just regular ones. + role: system + - content: Please call the "get_something_by_name" tool with non-existent parameters to test error handling + role: user + - role: assistant + tool_calls: + - function: + arguments: '{"invalid_param":"test"}' + name: get_something_by_name + id: pyd_ai_ad025dbe97d74d7f8693ee8fe14fa558 + type: function + - content: |- + 2 validation errors: [ + { + "type": "missing", + "loc": [ + "name" + ], + "msg": "Field required", + "input": { + "invalid_param": "test" + } + }, + { + "type": "extra_forbidden", + "loc": [ + "invalid_param" + ], + "msg": "Extra inputs are not permitted", + "input": "test" + } + ] + + Fix the errors and try again. + role: tool + tool_call_id: pyd_ai_ad025dbe97d74d7f8693ee8fe14fa558 + - role: assistant + tool_calls: + - function: + arguments: '{"name":"nonexistent"}' + name: get_something_by_name + id: fc_c8fd1e7c-0e6b-4a28-8ef2-516c38aa9ba8 + type: function + - content: 'Something with name: nonexistent' + role: tool + tool_call_id: fc_c8fd1e7c-0e6b-4a28-8ef2-516c38aa9ba8 + model: openai/gpt-oss-120b + n: 1 + stream: false + tool_choice: auto + tools: + - function: + description: '' + name: get_something_by_name + parameters: + additionalProperties: false + properties: + name: + type: string + required: + - name + type: object + type: function + uri: https://api.groq.com/openai/v1/chat/completions + response: + headers: + alt-svc: + - h3=":443"; ma=86400 + cache-control: + - private, max-age=0, no-store, no-cache, must-revalidate + connection: + - keep-alive + content-length: + - '1019' + content-type: + - application/json + transfer-encoding: + - chunked + vary: + - Origin + parsed_body: + choices: + - finish_reason: stop + index: 0 + logprobs: null + message: + content: 'Something with name: nonexistent' + reasoning: 'The user asked: "Please call the ''get_something_by_name'' tool with non-existent parameters to test + error handling". They wanted to test error handling with non-existent parameters, but we corrected to proper parameters. + The response from tool: "Something with name: nonexistent". Should we respond? Probably just output the result. + Follow developer instruction: be concise, no fancy quotes. Use regular quotes only.' + role: assistant + created: 1756847037 + id: chatcmpl-5b729d91-3507-4942-bd0d-27e7732afc6d + model: openai/gpt-oss-120b + object: chat.completion + service_tier: on_demand + system_fingerprint: fp_213abb2467 + usage: + completion_time: 0.205303865 + completion_tokens: 96 + prompt_time: 0.018679785 + prompt_tokens: 319 + queue_time: 2.222792642 + total_time: 0.22398365 + total_tokens: 415 + usage_breakdown: null + x_groq: + id: req_01k463wmgvfwwbcdj54311368h + status: + code: 200 + message: OK +version: 1 diff --git a/tests/models/cassettes/test_groq/test_tool_use_failed_error_streaming.yaml b/tests/models/cassettes/test_groq/test_tool_use_failed_error_streaming.yaml new file mode 100644 index 0000000000..f0dbb9c5c2 --- /dev/null +++ b/tests/models/cassettes/test_groq/test_tool_use_failed_error_streaming.yaml @@ -0,0 +1,527 @@ +interactions: +- request: + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '516' + content-type: + - application/json + host: + - api.groq.com + method: POST + parsed_body: + messages: + - content: Be concise. Never use pretty double quotes, just regular ones. + role: system + - content: Please call the "get_something_by_name" tool with non-existent parameters to test error handling + role: user + model: openai/gpt-oss-120b + n: 1 + stream: true + tool_choice: auto + tools: + - function: + description: '' + name: get_something_by_name + parameters: + additionalProperties: false + properties: + name: + type: string + required: + - name + type: object + type: function + uri: https://api.groq.com/openai/v1/chat/completions + response: + body: + string: |+ + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"role":"assistant","content":""},"logprobs":null,"finish_reason":null}],"x_groq":{"id":"req_01k464znyafc7r70nfs15f2x4n"}} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":"The","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" user","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" requests","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" to","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" call","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" the","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" tool","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" with","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" non","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":"-existent","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" parameters","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" to","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" test","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" error","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" handling","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":".","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" We","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" need","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" to","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" call","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" the","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" function","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" \"","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":"get","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":"_s","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":"omething","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":"_by","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":"_name","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":"\"","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" with","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" wrong","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" parameters","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":".","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" The","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" function","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" expects","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" a","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" single","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" argument","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" object","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" with","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" \"","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":"name","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":"\".","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" Non","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":"-existent","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" parameters","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" means","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" we","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" could","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" provide","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" a","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" wrong","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" key","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":",","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" or","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" missing","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" name","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":".","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" Let's","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" provide","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" an","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" object","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" with","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" wrong","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" key","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" \"","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":"non","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":"existent","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":"\":","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" \"","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":"value","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":"\".","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" That","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" should","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" cause","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" error","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":".","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" So","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" we","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" call","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" the","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" function","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" with","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" {\"","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":"non","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":"existent","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":"\":","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" \"","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":"test","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":"\"}","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":".\n\n","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":"We","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" need","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" to","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" output","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" the","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":" call","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-4e0ca299-7515-490a-a98a-16d7664d4fba","object":"chat.completion.chunk","created":1756848183,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"reasoning":".","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + event: error + data: {"error":{"message":"Tool call validation failed: tool call validation failed: parameters for tool get_something_by_name did not match schema: errors: [missing properties: 'name', additionalProperties 'nonexistent' not allowed]","type":"invalid_request_error","code":"tool_use_failed","failed_generation":"{\"name\": \"get_something_by_name\", \"arguments\": {\n \"nonexistent\": \"test\"\n}}","status_code":400}} + + headers: + alt-svc: + - h3=":443"; ma=86400 + cache-control: + - no-cache + connection: + - keep-alive + content-type: + - text/event-stream + transfer-encoding: + - chunked + vary: + - Origin + status: + code: 200 + message: OK +- request: + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '1200' + content-type: + - application/json + cookie: + - __cf_bm=VnLzgiU7OhCtZuk_OfkXJIaHGYuU0nLb_pGGGYJuVnM-1756848183-1.0.1.1-Yn4AMmjCNy14qzpBrpUCVZ5camA8xvr2Cyg.e_.u5GzC2zKZpdAK7hUtXVkDy69Ycn33Tj0YxWj1TJtUwlnYTUmSA_6GHoabbih938Div5o + host: + - api.groq.com + method: POST + parsed_body: + messages: + - content: Be concise. Never use pretty double quotes, just regular ones. + role: system + - content: Please call the "get_something_by_name" tool with non-existent parameters to test error handling + role: user + - content: '' + role: assistant + tool_calls: + - function: + arguments: '{"nonexistent":"test"}' + name: get_something_by_name + id: pyd_ai_5484149330864e21a69f40c7ce4e8d00 + type: function + - content: |- + 2 validation errors: [ + { + "type": "missing", + "loc": [ + "name" + ], + "msg": "Field required", + "input": { + "nonexistent": "test" + } + }, + { + "type": "extra_forbidden", + "loc": [ + "nonexistent" + ], + "msg": "Extra inputs are not permitted", + "input": "test" + } + ] + + Fix the errors and try again. + role: tool + tool_call_id: pyd_ai_5484149330864e21a69f40c7ce4e8d00 + model: openai/gpt-oss-120b + n: 1 + stream: true + tool_choice: auto + tools: + - function: + description: '' + name: get_something_by_name + parameters: + additionalProperties: false + properties: + name: + type: string + required: + - name + type: object + type: function + uri: https://api.groq.com/openai/v1/chat/completions + response: + body: + string: |+ + data: {"id":"chatcmpl-fffa1d41-1763-493a-9ced-083bd3f2d98b","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_ed9190d8b7","choices":[{"index":0,"delta":{"role":"assistant","content":""},"logprobs":null,"finish_reason":null}],"x_groq":{"id":"req_01k464zpjpfj1vgvw4c6m2fvd4"}} + + data: {"id":"chatcmpl-fffa1d41-1763-493a-9ced-083bd3f2d98b","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_ed9190d8b7","choices":[{"index":0,"delta":{"reasoning":"We","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fffa1d41-1763-493a-9ced-083bd3f2d98b","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_ed9190d8b7","choices":[{"index":0,"delta":{"reasoning":" need","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fffa1d41-1763-493a-9ced-083bd3f2d98b","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_ed9190d8b7","choices":[{"index":0,"delta":{"reasoning":" to","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fffa1d41-1763-493a-9ced-083bd3f2d98b","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_ed9190d8b7","choices":[{"index":0,"delta":{"reasoning":" call","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fffa1d41-1763-493a-9ced-083bd3f2d98b","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_ed9190d8b7","choices":[{"index":0,"delta":{"reasoning":" with","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fffa1d41-1763-493a-9ced-083bd3f2d98b","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_ed9190d8b7","choices":[{"index":0,"delta":{"reasoning":" correct","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fffa1d41-1763-493a-9ced-083bd3f2d98b","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_ed9190d8b7","choices":[{"index":0,"delta":{"reasoning":" param","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fffa1d41-1763-493a-9ced-083bd3f2d98b","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_ed9190d8b7","choices":[{"index":0,"delta":{"reasoning":":","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fffa1d41-1763-493a-9ced-083bd3f2d98b","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_ed9190d8b7","choices":[{"index":0,"delta":{"reasoning":" name","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fffa1d41-1763-493a-9ced-083bd3f2d98b","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_ed9190d8b7","choices":[{"index":0,"delta":{"reasoning":".","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fffa1d41-1763-493a-9ced-083bd3f2d98b","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_ed9190d8b7","choices":[{"index":0,"delta":{"reasoning":" Use","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fffa1d41-1763-493a-9ced-083bd3f2d98b","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_ed9190d8b7","choices":[{"index":0,"delta":{"reasoning":" a","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fffa1d41-1763-493a-9ced-083bd3f2d98b","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_ed9190d8b7","choices":[{"index":0,"delta":{"reasoning":" placeholder","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fffa1d41-1763-493a-9ced-083bd3f2d98b","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_ed9190d8b7","choices":[{"index":0,"delta":{"reasoning":" name","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fffa1d41-1763-493a-9ced-083bd3f2d98b","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_ed9190d8b7","choices":[{"index":0,"delta":{"reasoning":".","channel":"analysis"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fffa1d41-1763-493a-9ced-083bd3f2d98b","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_ed9190d8b7","choices":[{"index":0,"delta":{"tool_calls":[{"id":"fc_bc6fb53e-e06a-4106-bc42-cc5af9731e82","type":"function","function":{"name":"get_something_by_name","arguments":"{\"name\":\"test_name\"}"},"index":0}]},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fffa1d41-1763-493a-9ced-083bd3f2d98b","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_ed9190d8b7","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"tool_calls"}],"x_groq":{"id":"req_01k464zpjpfj1vgvw4c6m2fvd4","usage":{"queue_time":0.213579995,"prompt_tokens":283,"prompt_time":0.012023801,"completion_tokens":43,"completion_time":0.08558562,"total_tokens":326,"total_time":0.097609421}}} + + data: [DONE] + + headers: + alt-svc: + - h3=":443"; ma=86400 + cache-control: + - no-cache + connection: + - keep-alive + content-type: + - text/event-stream + transfer-encoding: + - chunked + vary: + - Origin + status: + code: 200 + message: OK +- request: + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate + connection: + - keep-alive + content-length: + - '1515' + content-type: + - application/json + cookie: + - __cf_bm=VnLzgiU7OhCtZuk_OfkXJIaHGYuU0nLb_pGGGYJuVnM-1756848183-1.0.1.1-Yn4AMmjCNy14qzpBrpUCVZ5camA8xvr2Cyg.e_.u5GzC2zKZpdAK7hUtXVkDy69Ycn33Tj0YxWj1TJtUwlnYTUmSA_6GHoabbih938Div5o + host: + - api.groq.com + method: POST + parsed_body: + messages: + - content: Be concise. Never use pretty double quotes, just regular ones. + role: system + - content: Please call the "get_something_by_name" tool with non-existent parameters to test error handling + role: user + - content: '' + role: assistant + tool_calls: + - function: + arguments: '{"nonexistent":"test"}' + name: get_something_by_name + id: pyd_ai_5484149330864e21a69f40c7ce4e8d00 + type: function + - content: |- + 2 validation errors: [ + { + "type": "missing", + "loc": [ + "name" + ], + "msg": "Field required", + "input": { + "nonexistent": "test" + } + }, + { + "type": "extra_forbidden", + "loc": [ + "nonexistent" + ], + "msg": "Extra inputs are not permitted", + "input": "test" + } + ] + + Fix the errors and try again. + role: tool + tool_call_id: pyd_ai_5484149330864e21a69f40c7ce4e8d00 + - content: '' + role: assistant + tool_calls: + - function: + arguments: '{"name":"test_name"}' + name: get_something_by_name + id: fc_bc6fb53e-e06a-4106-bc42-cc5af9731e82 + type: function + - content: 'Something with name: test_name' + role: tool + tool_call_id: fc_bc6fb53e-e06a-4106-bc42-cc5af9731e82 + model: openai/gpt-oss-120b + n: 1 + stream: true + tool_choice: auto + tools: + - function: + description: '' + name: get_something_by_name + parameters: + additionalProperties: false + properties: + name: + type: string + required: + - name + type: object + type: function + uri: https://api.groq.com/openai/v1/chat/completions + response: + body: + string: |+ + data: {"id":"chatcmpl-fe6b5685-166f-4c71-9cd7-3d5a97301bf1","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"role":"assistant","content":""},"logprobs":null,"finish_reason":null}],"x_groq":{"id":"req_01k464zq05fc8a5941vp8bgwtg"}} + + data: {"id":"chatcmpl-fe6b5685-166f-4c71-9cd7-3d5a97301bf1","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"content":"The"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fe6b5685-166f-4c71-9cd7-3d5a97301bf1","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"content":" tool"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fe6b5685-166f-4c71-9cd7-3d5a97301bf1","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"content":" call"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fe6b5685-166f-4c71-9cd7-3d5a97301bf1","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"content":" succeeded"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fe6b5685-166f-4c71-9cd7-3d5a97301bf1","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"content":" with"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fe6b5685-166f-4c71-9cd7-3d5a97301bf1","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"content":" the"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fe6b5685-166f-4c71-9cd7-3d5a97301bf1","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"content":" name"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fe6b5685-166f-4c71-9cd7-3d5a97301bf1","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"content":" \""},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fe6b5685-166f-4c71-9cd7-3d5a97301bf1","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"content":"test"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fe6b5685-166f-4c71-9cd7-3d5a97301bf1","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"content":"_name"},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fe6b5685-166f-4c71-9cd7-3d5a97301bf1","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{"content":"\"."},"logprobs":null,"finish_reason":null}]} + + data: {"id":"chatcmpl-fe6b5685-166f-4c71-9cd7-3d5a97301bf1","object":"chat.completion.chunk","created":1756848184,"model":"openai/gpt-oss-120b","system_fingerprint":"fp_213abb2467","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"x_groq":{"id":"req_01k464zq05fc8a5941vp8bgwtg","usage":{"queue_time":0.225905659,"prompt_tokens":320,"prompt_time":0.012202597,"completion_tokens":15,"completion_time":0.029861973,"total_tokens":335,"total_time":0.04206457}}} + + data: [DONE] + + headers: + alt-svc: + - h3=":443"; ma=86400 + cache-control: + - no-cache + connection: + - keep-alive + content-type: + - text/event-stream + transfer-encoding: + - chunked + vary: + - Origin + status: + code: 200 + message: OK +version: 1 +... diff --git a/tests/models/test_groq.py b/tests/models/test_groq.py index 714f82d903..ff46181610 100644 --- a/tests/models/test_groq.py +++ b/tests/models/test_groq.py @@ -1008,6 +1008,219 @@ async def test_groq_model_thinking_part_iter(allow_model_requests: None, groq_ap ) +async def test_tool_use_failed_error(allow_model_requests: None, groq_api_key: str): + m = GroqModel('openai/gpt-oss-120b', provider=GroqProvider(api_key=groq_api_key)) + agent = Agent(m, instructions='Be concise. Never use pretty double quotes, just regular ones.') + + @agent.tool_plain + async def get_something_by_name(name: str) -> str: + return f'Something with name: {name}' + + result = await agent.run( + 'Please call the "get_something_by_name" tool with non-existent parameters to test error handling' + ) + assert result.all_messages() == snapshot( + [ + ModelRequest( + parts=[ + UserPromptPart( + content='Please call the "get_something_by_name" tool with non-existent parameters to test error handling', + timestamp=IsDatetime(), + ) + ], + instructions='Be concise. Never use pretty double quotes, just regular ones.', + ), + ModelResponse( + parts=[ + ToolCallPart( + tool_name='get_something_by_name', + args={'invalid_param': 'test'}, + tool_call_id=IsStr(), + ) + ], + timestamp=IsDatetime(), + ), + ModelRequest( + parts=[ + RetryPromptPart( + content=[ + { + 'type': 'missing', + 'loc': ('name',), + 'msg': 'Field required', + 'input': {'invalid_param': 'test'}, + }, + { + 'type': 'extra_forbidden', + 'loc': ('invalid_param',), + 'msg': 'Extra inputs are not permitted', + 'input': 'test', + }, + ], + tool_name='get_something_by_name', + tool_call_id=IsStr(), + timestamp=IsDatetime(), + ) + ], + instructions='Be concise. Never use pretty double quotes, just regular ones.', + ), + ModelResponse( + parts=[ + ThinkingPart( + content='We need to call with correct param name: name. Provide a non-existent name perhaps "nonexistent".' + ), + ToolCallPart( + tool_name='get_something_by_name', + args='{"name":"nonexistent"}', + tool_call_id=IsStr(), + ), + ], + usage=RequestUsage(input_tokens=283, output_tokens=49), + model_name='openai/gpt-oss-120b', + timestamp=IsDatetime(), + provider_name='groq', + provider_response_id=IsStr(), + ), + ModelRequest( + parts=[ + ToolReturnPart( + tool_name='get_something_by_name', + content='Something with name: nonexistent', + tool_call_id=IsStr(), + timestamp=IsDatetime(), + ) + ], + instructions='Be concise. Never use pretty double quotes, just regular ones.', + ), + ModelResponse( + parts=[ + ThinkingPart( + content='The user asked: "Please call the \'get_something_by_name\' tool with non-existent parameters to test error handling". They wanted to test error handling with non-existent parameters, but we corrected to proper parameters. The response from tool: "Something with name: nonexistent". Should we respond? Probably just output the result. Follow developer instruction: be concise, no fancy quotes. Use regular quotes only.' + ), + TextPart(content='Something with name: nonexistent'), + ], + usage=RequestUsage(input_tokens=319, output_tokens=96), + model_name='openai/gpt-oss-120b', + timestamp=IsDatetime(), + provider_name='groq', + provider_response_id=IsStr(), + ), + ] + ) + + +async def test_tool_use_failed_error_streaming(allow_model_requests: None, groq_api_key: str): + m = GroqModel('openai/gpt-oss-120b', provider=GroqProvider(api_key=groq_api_key)) + agent = Agent(m, instructions='Be concise. Never use pretty double quotes, just regular ones.') + + @agent.tool_plain + async def get_something_by_name(name: str) -> str: + return f'Something with name: {name}' + + async with agent.iter( + 'Please call the "get_something_by_name" tool with non-existent parameters to test error handling' + ) as agent_run: + async for node in agent_run: + if Agent.is_model_request_node(node) or Agent.is_call_tools_node(node): + async with node.stream(agent_run.ctx) as request_stream: + async for _ in request_stream: + pass + + assert agent_run.result is not None + assert agent_run.result.all_messages() == snapshot( + [ + ModelRequest( + parts=[ + UserPromptPart( + content='Please call the "get_something_by_name" tool with non-existent parameters to test error handling', + timestamp=IsDatetime(), + ) + ], + instructions='Be concise. Never use pretty double quotes, just regular ones.', + ), + ModelResponse( + parts=[ + TextPart(content=''), + ToolCallPart( + tool_name='get_something_by_name', + args={'nonexistent': 'test'}, + tool_call_id=IsStr(), + ), + ], + model_name='openai/gpt-oss-120b', + timestamp=IsDatetime(), + provider_name='groq', + ), + ModelRequest( + parts=[ + RetryPromptPart( + content=[ + { + 'type': 'missing', + 'loc': ('name',), + 'msg': 'Field required', + 'input': {'nonexistent': 'test'}, + }, + { + 'type': 'extra_forbidden', + 'loc': ('nonexistent',), + 'msg': 'Extra inputs are not permitted', + 'input': 'test', + }, + ], + tool_name='get_something_by_name', + tool_call_id=IsStr(), + timestamp=IsDatetime(), + ) + ], + instructions='Be concise. Never use pretty double quotes, just regular ones.', + ), + ModelResponse( + parts=[ + TextPart(content=''), + ToolCallPart( + tool_name='get_something_by_name', + args='{"name":"test_name"}', + tool_call_id=IsStr(), + ), + ], + usage=RequestUsage(input_tokens=283, output_tokens=43), + model_name='openai/gpt-oss-120b', + timestamp=IsDatetime(), + provider_name='groq', + ), + ModelRequest( + parts=[ + ToolReturnPart( + tool_name='get_something_by_name', + content='Something with name: test_name', + tool_call_id=IsStr(), + timestamp=IsDatetime(), + ) + ], + instructions='Be concise. Never use pretty double quotes, just regular ones.', + ), + ModelResponse( + parts=[TextPart(content='The tool call succeeded with the name "test_name".')], + usage=RequestUsage(input_tokens=320, output_tokens=15), + model_name='openai/gpt-oss-120b', + timestamp=IsDatetime(), + provider_name='groq', + ), + ] + ) + + +async def test_tool_regular_error(allow_model_requests: None, groq_api_key: str): + m = GroqModel('non-existent', provider=GroqProvider(api_key=groq_api_key)) + agent = Agent(m) + + with pytest.raises( + ModelHTTPError, match='The model `non-existent` does not exist or you do not have access to it.' + ): + await agent.run('hello') + + async def test_groq_native_output(allow_model_requests: None, groq_api_key: str): m = GroqModel('openai/gpt-oss-120b', provider=GroqProvider(api_key=groq_api_key))