agentscope-ai / agentscope-ai/agentscope-runtime
[Bug] OpenAI Responses stream shows no tool calls even when the assistant claims to use tools
- Vorherrschende Sprache
- Python
- Sterne
- 863
- Forks
- 168
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
## Bug Description
When using AgentScope Runtime through an OpenAI-compatible Responses API endpoint, the streamed server response contains only assistant text messages and no tool-call output items, even though the assistant explicitly says it is going to inspect a skill and use the terminal tool, and the server shows tool execution logs.
In the captured response, the assistant says it will check the skill details and use it through the terminal, then later says it used a fibonacci generator script, but the `response.completed` payload still has `tools: []` and the output only contains plain assistant messages. This makes the tool execution either invisible or incorrectly formatted for OpenAI Responses clients.
This was tested using the OpenAI Responses formatter/shape, and the HTTP request/response was captured with HTTP Toolkit while exercising the endpoint from OpenWebUI.
Important context: I am not using the built-in AgentScope sandbox. I am using my own sandbox integration, and that part works. I also use a custom `register_tools(...)` helper to register tools into the toolkit, and that also works. The problem appears to be in the runtime/adapter/formatter layer that exposes the agent through the OpenAI-compatible Responses API.
## Affected Component
- [x] Engine
- [ ] Sandbox
- [ ] Tools
- [ ] Common
- [ ] Documentation
- [x] Other: OpenAI-compatible Responses API formatting/streaming
## Reproduction Steps
1. Create an AgentScope Runtime app that exposes an AgentScope agent through an OpenAI-compatible endpoint. The relevant server-side setup is:
```python
from agentscope.agent import ReActAgent
from agentscope.formatter import OpenAIChatFormatter
from agentscope.model import OpenAIChatModel
from agentscope.pipeline import stream_printing_messages
from agentscope.tool import Toolkit
from agentscope_runtime import AgentApp
from agentscope_runtime.adapters import ResponseAPIDefaultAdapter
from agentscope_runtime.engine.schemas.agent_schemas import AgentRequest
responses_api_adapter = ResponseAPIDefaultAdapter()
agent_app = AgentApp(
app_name="Agent Test App",
app_description="Agent Test - to test AgentScope",
lifespan=lifespan,
protocol_adapters=[responses_api_adapter],
)
@agent_app.query(framework="agentscope")
async def query_func(self, msgs, request: AgentRequest = None, **kwargs):
managed_sandbox = await depends.services.sandbox()
toolkit = Toolkit()
# Custom helper that registers my tools into the toolkit. This part works.
register_tools(
toolkit=toolkit,
tools=[
ToolName.TERMINAL,
],
sandbox=managed_sandbox,
)
agent = ReActAgent(
name="Agent Test",
model=OpenAIChatModel(
model_name=settings.LLM_MODEL,
api_key=settings.API_KEY,
enable_thinking=True,
stream=True,
client_kwargs={"base_url": ""},
),
sys_prompt=system_prompt,
toolkit=toolkit,
memory=AsyncSQLAlchemyMemory(...),
formatter=OpenAIChatFormatter(),
)
agent.set_console_output_enabled(enabled=False)
# Custom sandbox integration is used here instead of the built-in AgentScope sandbox.
async for msg, last in stream_printing_messages(
agents=[agent],
coroutine_task=agent(msgs),
):
yield msg, last
```
2. Send an OpenAI Responses API request similar to:
```json
{
"stream": true,
"model": "aumo_data_analyst",
"input": [
{
"type": "message",
"role": "user",
"content": [
{
"type": "input_text",
"text": "Use your fibonacci skill through the terminal tool to tell me what the is the 10th number in the fibonacci sequence"
}
]
}
]
}
```
3. Run the server and access it through an OpenAI-compatible client. In my case, I used OpenWebUI.
4. Capture the streamed HTTP response. In my case I used HTTP Toolkit to inspect the raw SSE events.
5. Ask the model to something to make it use a tool, in my case I asked `Use your fibonacci skill through the terminal tool to tell me what the is the 10th number in the fibonacci sequence` to make it use the terminal tool.
6. Observe that the assistant says it will use the tool, but the response stream only emits text messages and no tool-call items.
## Expected vs Actual Behavior
**Expected:** If the agent actually performs tool usage, the OpenAI Responses stream should include tool-related output items/events in a way that OpenAI-compatible clients can consume, rather than only assistant text that narrates tool usage. If no tool was executed, the assistant should not claim that it checked skill details or used the terminal/script.
**Actual:** The assistant text claims it checked the skill details, used the terminal, and ran a fibonacci generator script, but the streamed response contains only `message` items with `output_text`. The final payload also reports `tools: []`, so from the client side there is no visible tool execution at all.
## Error Messages
There is no server exception in the captured data. The issue is an incorrect/misleading OpenAI Responses-formatted stream.
Relevant evidence from the final streamed payload:
```text
"tools": [],
"output": [
{"type": "message", ...},
{"type": "message", ...},
{"type": "message", ...}
]
```
The assistant-generated text includes statements such as:
```text
"Let me first check the skill details and then use it through the terminal."
"Now let me use the fibonacci generator script to find the 10th number in the Fibonacci sequence:"
```
## Environment
- **AgentScope Runtime Version:** v1.1.3
- **Python Version:** 3.13.7
- **OS:** Windows 10 with WSL (Linux environment inside WSL)
- **Installation:** pip-style installation managed with `uv` (`uv venv`, `uv init`, `uv add agentscope-runtime`, `uv lock --upgrade-package agentscope-runtime`)
## Additional Context
- I selected the bug template because this appears to be incorrect behavior rather than a feature request or documentation gap.
- The issue may sit specifically in the OpenAI-compatible Responses adapter / formatter / streaming translation layer, not necessarily in the underlying agent execution itself.
- The raw request and response used for this report are attached in `agentscope_runtime_issue_raw_data.md`.
- The client path used during testing was OpenWebUI -> OpenAI-compatible AgentScope Runtime endpoint.
- HTTP Toolkit was used only to inspect/capture the raw HTTP request and SSE response.
- I am not using the built-in AgentScope sandbox. I use my own sandbox integration, and it works for executing tools.
- `register_tools(...)` is my own helper for registering tools, and it also works.
- Because the agent appears to execute successfully while the OpenAI Responses stream only contains text messages with `tools: []`, the bug seems more likely to be in the response adaptation/formatting layer than in the custom sandbox or tool registration code.
[agentscope_runtime_issue_raw_data.md](https://github.com/user-attachments/files/26728069/agentscope_runtime_issue_raw_data.md)
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.