alfin06/swegent-issues-filtered huggingface dataset:
Support correct and lossless reconstruction of OpenAI messages when streaming for multi-turn conversation (needed for deep research etc.)

### Description

**Streaming Response Message Reconstruction Issue:** 

The current streaming implementation cannot correctly reconstruct the `(await result.response).messages` array from streaming deltas, which prevents proper multi-turn conversation continuity. Specific issues include:

- **Complex Reasoning Structure**: Reasoning items can contain arrays of summary texts that cannot be properly reconstructed from individual deltas
- **Missing Output Index**: The `output_index` needed to correctly place chunk deltas in the final array structure is not exposed to consumers
- **Incomplete State Building**: The streaming parser does not correctly build the final message state from deltas, particularly for complex reasoning content
- **Multi-turn Conversation Breakage**: For deep research models and similar advanced reasoning models, users cannot continue conversations with the correct message prefix without implementing custom parsing logic

This means that for streaming scenarios with reasoning models, developers currently need to either:
1. Use non-streaming mode for multi-turn conversations, or  
2. Implement custom delta parsing logic (which lacks access to necessary metadata like `output_index`)

See real output from responses API to highlight this issue:

```
curl https://api.openai.com/v1/responses \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "o3-deep-research",
    "input": "Research the economic impact of semaglutide on global healthcare systems. Include specific figures, trends, statistics, and measurable outcomes. Prioritize reliable, up-to-date sources: peer-reviewed research, health organizations (e.g., WHO, CDC), regulatory agencies, or pharmaceutical earnings reports. Include inline citations and return all source metadata. Be analytical, avoid generalities, and ensure that each section supports data-backed reasoning that could inform healthcare policy or financial modeling.",
    "tools": [
      { "type": "web_search_preview" }
    ],
    "reasoning": {
      "effort": "medium", 
      "summary": "auto"
    },
    "include": ["reasoning.encrypted_content"],
    "stream": true
  }'
```



### AI SDK Version

_No response_

Labels: feature, ai/provider, provider/openai
State: closed
[Bug] Gemini 输出不完整，总是缺少最后几个字

### 📦 部署环境

Docker

### 📦 部署模式

服务端模式(lobe-chat-database 镜像)

### 📌 软件版本

v1.71.0

### 💻 系统环境

macOS

### 🌐 浏览器

Edge

### 🐛 问题描述

Gemini 的输出总是被截断，缺少最后几个字。

![Image](https://github.com/user-attachments/assets/49ba7d67-ec16-433d-b5a1-b10f82a8b2bd)

服务器在新加坡，未修改模型 max token 等。

![Image](https://github.com/user-attachments/assets/21384be6-3f1f-4b9a-b483-e7857119be43)

### 📷 复现步骤

1. 输入
>>> 请原样输出我下面这段话：
在创建新的 Issue 之前，请先搜索已有问题，如果发现已有类似的问题，请给它 👍 点赞，这样可以帮助我们更快地解决问题。
如果你在使用过程中遇到问题，可以尝试以下方式获取帮助：
在 GitHub Discussions 的版块发起讨论。
在 LobeChat 社区 提问，与其他用户交流。

2. 得到输出
>>> 在创建新的 Issue 之前，请先搜索已有问题，如果发现已有类似的问题，请给它 👍 点赞，这样可以帮助我们更快地解决问题。
如果你在使用过程中遇到问题，可以尝试以下方式获取帮助：
在 GitHub Discussions 的版块发起讨论。
在 LobeChat 社区 

### 🚦 期望结果

Gemini 能够正常输出完整回答。

### 📝 补充信息

_No response_

Labels: released
State: closed
MCP tools with complex input schema (array)

### What happened?

**Describe the bug**
  The _json_schema_to_model function in autogen_core.utils._json_to_pydantic does not properly handle array items that have object schemas with properties. When an array's items schema defines an object with specific properties, those properties are not processed, resulting in models
  with additionalProperties=True instead of the defined fields.

  **Expected Behavior**

  Array items with object schemas should have their properties properly converted to Pydantic model fields.

  **Actual Behavior**

  Array items with object schemas fall back to generic objects with additionalProperties=True, losing the specific field definitions.

 **Root Cause**

  In _json_schema_to_model (line 275), the function only loops through schema.get("properties", {}).items(). For arrays, the _extract_field_type method processes the items schema but doesn't recursively call _json_schema_to_model when the item schema is an object with properties.

  **Example**

  Input Schema:
```
  {
    "type": "object",
    "properties": {
      "users": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "name": {"type": "string"},
            "email": {"type": "string"},
            "age": {"type": "integer"}
          },
          "required": ["name", "email"]
        }
      }
    }
  }
```

  **Expected Result:**
  A Pydantic model where users is List[UserModel] with UserModel having name, email, and age fields.

  **Actual Result:**
  A Pydantic model where users is List[dict] with additionalProperties=True, losing the specific field structure.

  **Code Location**

  File: autogen_core/utils/_json_to_pydantic.py
  Function: _extract_field_type (around line 229)
  Issue: When processing item_schema, it doesn't recursively handle object schemas with properties.

  Environment

  - Python version: 3.13.1
  - autogen version: 0.7.2





### Which packages was the bug in?

Python Core (autogen-core)

### AutoGen library version.

Python 0.7.2

### Other library version.

_No response_

### Model used

gpt-4.1

### Model provider

OpenAI

### Other model provider

_No response_

### Python version

3.13

### .NET version

None

### Operating system

None

Labels: needs-triage
State: closed
OllamaChatCompletionClient load_component() error

### What happened?



```python
import asyncio
from autogen_core.models import ChatCompletionClient, UserMessage

async def main():

    config = {
        "provider": "OllamaChatCompletionClient",
        "config": {
            "model": "qwen3",  # The Ollama model to use
            "host": "http://1.2.3.4:30130",
        }
    }

    client = ChatCompletionClient.load_component(config)

if __name__ == "__main__":
    asyncio.run(main())
```

the error is shown:

```
Traceback (most recent call last):
  File "/var/spool/autogen-dev/codes/autogen-tutorials/./ag_infra_test_04_ollama_test_2.py", line 19, in <module>
    asyncio.run(main())
  File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/var/spool/autogen-dev/codes/autogen-tutorials/./ag_infra_test_04_ollama_test_2.py", line 16, in main
    client = ChatCompletionClient.load_component(config)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/autogen_core/_component_config.py", line 223, in load_component
    raise ValueError("Invalid")
ValueError: Invalid
```

However, the following code works with the same configuration:

```python
import asyncio
from autogen_ext.models.ollama import OllamaChatCompletionClient

async def main():

    client = OllamaChatCompletionClient(
        model="qwen3", host = "http://1.2.3.4:30130"
        )

if __name__ == "__main__":
    asyncio.run(main())
```

Any suggestion? 

Thanks.

### Which packages was the bug in?

Python AgentChat (autogen-agentchat>=0.4.0)

### AutoGen library version.

Python 0.7.4

### Other library version.

_No response_

### Model used

qwen3

### Model provider

Ollama

### Other model provider

_No response_

### Python version

3.11

### .NET version

None

### Operating system

Ubuntu

Labels: needs-triage
State: closed
[Request] 希望增加cohere的模型服务

### 🥰 需求描述

cohere新推出了command a，用起来还不错，希望能增加这个模型供应商，现在手动添加好像报错？

### 🧐 解决方案

系统级别增加cohere模型供应商

### 📝 补充信息

_No response_

Labels: released, Model Provider
State: closed
Whenever an API/Model error  is surfaced, return the control to the user

### What happened?

Whenever we are processing the stream and there is an error, if we continue the flow and let the nextSpeakerCheck run, there is a chance that it will choose the model to run again.

When that happens, the client retries the existing history and duplicates the responses like the one that was interrupted. This can even enter into a loop. 




### What did you expect to happen?

Control should go back to the user. 

### Client information

<details>

```console
$ gemini /about
# paste output here
```

</details>

### Login information

_No response_

### Anything else we need to know?

<img width="1730" height="760" alt="Image" src="https://github.com/user-attachments/assets/9bfcf4a9-e971-4307-99d7-cc14b7536aea" />

Labels: priority/p0
State: closed
OpenRouter APIKey无法正确填入

### 📦 部署环境

Docker

### 📦 部署模式

服务端模式(lobe-chat-database 镜像)

### 📌 软件版本

v1.71.5

### 💻 系统环境

Other Linux

### 🌐 浏览器

Chrome, Edge

### 🐛 问题描述

填入OpenRouter的Key之后检查key的时候总是提示APIKey不正确或为空，点到其他API提供商然后再点回OpenRouter的配置页面之后会发现Key已经被清空了，其他服务商没有这个问题。

### 📷 复现步骤

填入OpenRouter的Key，检查连通性

### 🚦 期望结果

正确保存OpenRouter的Key

### 📝 补充信息

_No response_

Labels: released, unconfirm
State: closed
Maintain alternating chat history for empty or thought-only model responses

### What happened?

The issue is a flaw in the `recordHistory` method's logic. When the model's response contained only non-visible content (like a `thought` part), the method would filter it out but then fail to add a placeholder empty `model` turn. This would either leave two consecutive `user` turns in the history (in streaming mode) or simply an incomplete turn, causing tests to fail and breaking conversational integrity.

### What did you expect to happen?

The user and model turns should alternate.

### Client information

<details>

TBD

</details>

### Login information

_No response_

### Anything else we need to know?

_No response_

Labels: area/core
State: closed
Missing reasoning_effort for gpt-5 models in openai config

### What happened?

**Describe the bug**
It is not possible to set the reasoning_effort via ChatCompletionClient.load_component(config) for gpt-5 models. Using the setting is being ignored. 

```python

import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_core.models import ChatCompletionClient

config = {
        "provider": "AzureOpenAIChatCompletionClient",
        "config": {
            "azure_endpoint": "****",
            "azure_deployment": "gpt-5-2025-08-07",
            "azure_ad_token_provider": {
                "provider": "autogen_ext.auth.azure.AzureTokenProvider",
                "config": {
                    "provider_kind": "DefaultAzureCredential",
                    "scopes": ["****/.default"],
                },
            },
            "api_version": "2025-02-01-preview",
            "model": "gpt-5",
            "temperature": 1,
            "seed": 42,
            "reasoning_effort": "low",
        }
}

model_client = ChatCompletionClient.load_component(config)

# Create agents
agent = AssistantAgent(
    name="Assistant",
    system_message="You are a helpful assistant",
    model_client=model_client,
)

async def main():
    result = await agent.run(task="Find information on AutoGen")
    print(result.messages)

if __name__ == "__main__":
    asyncio.run(main())
```

Raw config:
```python
_raw_config = {'api_version': '2025-02-01-preview', 'azure_ad_token_provider': <autogen_ext.auth.azure.AzureTokenProvider object at 0x10e340d70>, 'azure_deployment': 'gpt-5-2025-08-07', 'azure_endpoint': '****', 'model': 'gpt-5', 'seed': 42, 'temperature': 1.0}
```

**To Reproduce**
Run above snippet with valid azure openai endpoint and credentials.


**Expected behavior**
Model is ran with reasoning_effort set to low.


**Additional context**
In the docs you can also see it's not present. 

https://microsoft.github.io/autogen/stable//reference/python/autogen_ext.models.openai.config.html#autogen_ext.models.openai.config.BaseOpenAIClientConfiguration



### Which packages was the bug in?

Python Core (autogen-core)

### AutoGen library version.

Python 0.7.4

### Other library version.

_No response_

### Model used

gpt-5-2025-08-07

### Model provider

Azure OpenAI

### Other model provider

_No response_

### Python version

3.13

### .NET version

None

### Operating system

MacOS

Labels: needs-triage
State: closed
关于FunctionFormatter中think标签的疑问

### Reminder

- [x] I have read the above rules and searched the existing issues.

### System Info

llamafactory-cli train，sft

### Reproduction

您好，我对FunctionFormatter.apply中think标签的处理有一些疑问。
`function_str = thought.group(1) + function_str`，拼接后的str是

`think<func_call>function call</func_call>`      thought.group(1)导致缺少了think标签。

这里用thought.group(0)
`<think>think</think>\n\n<func_call>function call</func_call>`是不是会好一些？


```
@dataclass
class FunctionFormatter(StringFormatter):
    def __post_init__(self):
        super().__post_init__()
        self.tool_utils = get_tool_utils(self.tool_format)

    @override
    def apply(self, **kwargs) -> SLOTS:
        content: str = kwargs.pop("content")
        regex = re.compile(r"<think>(.*)</think>", re.DOTALL)
        thought = re.search(regex, content)
        if thought:
            content = content.replace(thought.group(0), "")

        functions: List["FunctionCall"] = []
        try:
            tool_calls = json.loads(content)
            if not isinstance(tool_calls, list):  # parallel function call
                tool_calls = [tool_calls]

            for tool_call in tool_calls:
                functions.append(
                    FunctionCall(tool_call["name"], json.dumps(tool_call["arguments"], ensure_ascii=False))
                )

        except json.JSONDecodeError:
            raise RuntimeError(f"Invalid JSON format in function message: {str([content])}.")  # flat string

        function_str = self.tool_utils.function_formatter(functions)
        if thought:
            function_str = thought.group(1) + function_str

        return super().apply(content=function_str)
```

### Others

_No response_

Labels: solved
State: closed
gemini-openai-compatible support reasoningEffort: 'none'

### Description

https://ai.google.dev/gemini-api/docs/openai#thinking

but it is limited in code:

https://github.com/vercel/ai/blob/82fc049a8c3a6d1da04a23ad828f77fbfdb33802/packages/openai-compatible/src/openai-compatible-chat-options.ts#L11-L20

### AI SDK Version

v5

Labels: bug, ai/provider, provider/google, provider/openai-compatible
State: closed
Improving Pro Model Quota Handling in the CLI

### What would you like to be added?

## Problem

When a user exceeds their daily usage quota for a **Pro model**, the CLI tool currently **auto-switches to a fallback model** (e.g., Flash) for the rest of the session.  


---

## Why is this needed?

Previously, after hitting the quota limit:  

- The CLI would show a basic notification.  
- The user was dropped back to a state where they had to **manually re-run `/auth`** if they wanted to switch to a different API key.  
- If they continued with Flash and they had no idea about Ctrl+P, they had to retype their last prompt from scratch.  

This caused unnecessary friction and confusion.

---

## Solution

We’ve introduced a new **ProQuotaDialog** that appears when a Pro model quota limit is reached.  
This dialog makes the situation clear and offers two direct choices:

1. **Authenticate**  
   - Run the `/auth` command directly from the dialog.  
   - Switch to a different API key (e.g., a paid key with higher limits) and continue using the Pro model.

2. **Continue with Fallback (Flash)**  
   - Stay in the session using the designated fallback model.  
   - **New tip**: The dialog reminds the user they can press `Ctrl+P` to quickly recall their recent prompt, so they don’t need to retype it again.  

---

## Benefits

This change improves the user experience by:

- **Transparency**: Users are explicitly informed when they hit quota limits.  
- **Control**: Users can re-authenticate or continue with the fallback model directly from the dialog.  
- **Efficiency**: With the `Ctrl+P` tip, users can quickly reuse recent prompts when switching to Flash.  


### Why is this needed?

Previously, after hitting the quota limit:  

- The CLI would show a basic notification.  
- The user was dropped back to a state where they had to **manually re-run `/auth`** if they wanted to switch to a different API key.  
- If they continued with Flash and had no idea about ctrl+p, they had to retype their last prompt from scratch.  

This caused unnecessary friction and confusion.

---

## Solution

We’ve introduced a new **ProQuotaDialog** that appears when a Pro model quota limit is reached.  
This dialog makes the situation clear and offers two direct choices:

1. **Authenticate**  
   - Run the `/auth` command directly from the dialog.  
   - Switch to a different API key (e.g., a paid key with higher limits) and continue using the Pro model.

2. **Continue with Fallback (Flash)**  
   - Stay in the session using the designated fallback model.  
   - **New tip**: The dialog reminds the user they can press `Ctrl+P` to quickly recall their recent prompt, so they don’t need to retype it again.  

---

## Benefits

This change improves the user experience by:

- **Control**: Users can re-authenticate or continue with the fallback model directly from the dialog.  
- **Efficiency**: With the `Ctrl+P` tip, users can quickly reuse recent prompts when switching to Flash.  


### Additional context

_No response_

State: closed
Beta 5 - Incomplete tool input part breaking the whole chat history

### Description

When there is an invalid tool call in history, the convertToModelMessages fails to convert to model messages, breaking the whole experience and forcing the user to start a new chat session. It should probably just be ignored so the user can keep with their chat session.

After a tool has called with invalid input, the user cannot move forward in the same chat session as it throws this:

```ts
Chat Client Tools API error: Error [AI_MessageConversionError]: incomplete tool input is not supported: call_cFYQgCzSZOqMLrd0EAeNrIMY
    at POST (src/app/api/chat-client-tools/route.ts:11:39)
   9 |     const result = streamText({
  10 |       model: openai('gpt-4o-mini'),
> 11 |       messages: convertToModelMessages(messages),
     |                                       ^
  12 |       tools: {
  13 |         updateSlide,
  14 |       }, {
  cause: undefined,
  originalMessage: [Object]
}
 POST /api/chat-client-tools 500 in 80ms
```

### AI SDK Version

  "@ai-sdk/openai": "2.0.0-beta.5",
    "@ai-sdk/react": "2.0.0-beta.7",

Labels: bug, ai/core, ai/provider, provider/openai
State: closed
Gemma 3 Model error

### 📦 Platform

Self hosting Docker

### 📦 Deploymenet mode

client db (lobe-chat image)

### 📌 Version

latest

### 💻 Operating System

macOS, Ubuntu

### 🌐 Browser

Firefox

### 🐛 Bug Description

Gemma 3 always errors with
```
{
  "error": {
    "message": "Developer instruction is not enabled for models/gemma-3-27b-it",
    "statusCode": 400,
    "statusCodeText": "[400 Bad Request]"
  },
  "provider": "google"
}
```

### 📷 Recurrence Steps

1. initiate a session with Google Gemma 3 Model
2. observe the above error

### 🚦 Expected Behavior

chat continues without error

### 📝 Additional Information

_No response_

Labels: Inactive, released, unconfirm
State: closed
1.74.10/1.74.9 - Error: you must `import '@anthropic-ai/sdk/shims/web'` before importing anything else from @anthropic-ai/sdk

### 📦 Platform

Self hosting Docker

### 📦 Deploymenet mode

server db(lobe-chat-database image)

### 📌 Version

1.74.10/1.74.9

### 💻 Operating System

Ubuntu

### 🌐 Browser

Chrome

### 🐛 Bug Description

After the last update, an error message appears. I checked it on two versions, rolled back to 1.74.8


Error: you must `import '@anthropic-ai/sdk/shims/web'` before importing anything else from @anthropic-ai/sdk

    at u (.next/server/chunks/4870.js:103:154108)

    at 833206 (.next/server/chunks/4870.js:204:36230)

    at t (.next/server/webpack-runtime.js:1:143)

    at 196865 (.next/server/chunks/98899.js:124:9721)

    at t (.next/server/webpack-runtime.js:1:143)

    at <unknown> (.next/server/chunks/98899.js:1067:309)

    at t.a (.next/server/webpack-runtime.js:1:989)

    at 815998 (.next/server/chunks/98899.js:1067:125)

    at t (.next/server/webpack-runtime.js:1:143)

    at <unknown> (.next/server/chunks/98899.js:1:11852) {

  digest: '1905723649'

}

### 📷 Recurrence Steps

_No response_

### 🚦 Expected Behavior

_No response_

### 📝 Additional Information

_No response_

Labels: released, unconfirm
State: closed
Add support for Bedrock API keys

### Description

Amazon Bedrock [just announced](https://aws.amazon.com/about-aws/whats-new/2025/07/amazon-bedrock-api-keys-for-streamlined-development/) support for API Keys as auth method as an alternative to IAM credentials.

This will simplify onboarding and configuration when using the provider.

My team is willing to implement this feature into the AI SDK, if the idea is welcome please assign the issue to me.

### AI SDK Version

All

Labels: feature, ai/provider, provider/amazon-bedrock
State: closed
allow editing the stepInputMessages through prepareStep

### Description

Would it be possible to also allow editing the stepInputMessages through prepareStep?
I am using an agent with many steps, and often it accumulates input tokens, increasing the cost greatly. (if accumulated 5K tokens and have 20 more steps, I am paying for 100K tokens for the steps.)
I hope to apply cacheControl option to one of the stepInputMessages in the middle of streamText steps to decrease the cost burden.

Thank you!

### AI SDK Version

aisdk: 5.0 beta


related PR:
https://github.com/vercel/ai/pull/5991

Labels: feature, ai/core
State: closed
v5 tool printing message twice when used onFinish callback in result.toUIMessageStreamResponse

### Description

So what happening is when i add the `onFinish` callback to `toUIMessageStreamResponse` the chat starts adding the tool output twice on the Messages

if we comment out the `onFinish` callback it works fine again

```
 return result.toUIMessageStreamResponse({
    onFinish: ({ messages }) => {
      console.log('onFinish', messages);
    },
  });
```

## How to test
- Clone https://github.com/khanakia/vercel_ai_doublemessagebug
- `pnpm i`
- `pnpm dev`
- Open http://localhost:3000/use-chat-tools
- type `contact`
- Click the YES in the tool button


<img width="508" height="506" alt="Image" src="https://github.com/user-attachments/assets/b9f156b5-4c7b-44b5-9708-05093f1ee801" />


https://github.com/user-attachments/assets/e9a9fb7b-3393-4e1c-a4c6-87f4db1a2698

### AI SDK Version

```
"@ai-sdk/openai": "2.0.0-beta.5",
"@ai-sdk/provider-utils": "3.0.0-beta.2",
"@ai-sdk/react": "2.0.0-beta.9",
"ai": "5.0.0-beta.9",
```

Labels: bug, ai/ui, ai/provider, provider/openai
State: closed
v5 can't override generateId in generateText / streamText

### Description

On v5 it looks like the `experimental_generateId` has been removed, preventing the user from overriding the messageId generator, it seems there's no way to do this now.

I see there's a `generateId` in `createUIMessageStream` but it doesn't seem to have any effect, as the generated Id is overridden by the default implementation in streamText.

### AI SDK Version

- ai: 5.0.0-beta.12

Labels: bug, ai/core, ai/provider
State: closed