agentscope-ai / agentscope-ai/QwenPaw
[Bug]: Model 'unknown' execution failed. Reason: `_StructuredOutputDynamicClass` is not fully defined
- Ngôn ngữ chính
- Python
- Star
- 34.9k
- Fork
- 3.1k
- Merge trung bình
- 1 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 225
Mô tả
QwenPaw Version
v2.1.0
Description
When running the console channel, QwenPaw fails during agent/toolkit initialization with a MODEL_EXECUTION_ERROR. The root cause is a Pydantic error: _StructuredOutputDynamicClass is not fully defined; the system suggests defining Optional and calling model_rebuild(). The error occurs while building the tool registry, specifically when extracting the input schema for a PolicyGuardedTool via agentscope. The error dump is saved to /tmp/qwenpaw_query_error_p83cxypo.json.
Expected behavior: The console should start successfully, and tools should be registered without Pydantic validation errors.
Related PR(s): None
Security considerations: None (no authentication or sensitive configuration exposed)
Component(s) Affected
☑ Core / Backend (specifically tool registration, agent runtime, and structured output parsing)
☑ Console (frontend web UI – triggered via console channel)
□ Channels (DingTalk, Feishu, QQ, Discord, iMessage, etc.)
□ Skills
□ CLI
□ Documentation
□ Tests
□ CI/CD
□ Scripts / Deploy
Environment
QwenPaw version: v2.1.0
OS: Linux (Docker container)
Install method: Docker
Python version: 3.11 (as seen in the venv path: venv/lib/python3.11)
Steps to Reproduce
Start the QwenPaw Docker container using the official image for v2.1.0.
Access the console UI (or trigger a query via the console channel).
The error occurs during the runtime build phase, specifically when the system attempts to build the toolkit and register tools (e.g., recall_history_python). The console fails with the above error.
Note: The error may be reproducible simply by starting the console, as the tool registration is part of the startup sequence.
Actual vs Expected
Actual: The console channel fails to process the request (or fails on startup) and throws a MODEL_EXECUTION_ERROR with the Pydantic class-not-fully-defined error. The error is logged, and a dump file is created.
Expected: The console should start successfully, tools should be registered, and queries should be processed normally.
Logs / Screenshots
The following relevant log excerpts show the full stack trace and context:
text
2026-08-17 07:27:14 | ERROR | venv/lib/python3.11/site-packages/qwenpaw/app/channels/console/channel.py:526 | console process/reply failed
2026-08-17 07:27:14 | INFO | venv/lib/python3.11/site-packages/qwenpaw/hooks/error/error_hook.py:61 | error_normalize: dump written to /tmp/qwenpaw_query_error_p83cxypo.json
For further information visit https://errors.pydantic.dev/2.13/u/class-not-fully-defined
pydantic.errors.PydanticUserError: `_StructuredOutputDynamicClass` is not fully defined; you should define `Optional`, then call `_StructuredOutputDynamicClass.model_rebuild()`.
raise PydanticUserError(self._error_message, code=self._code)
File "/app/venv/lib/python3.11/site-packages/pydantic/_internal/_mock_val_ser.py", line 67, in rebuild
cls.__pydantic_core_schema__.rebuild()
File "/app/venv/lib/python3.11/site-packages/pydantic/json_schema.py", line 2557, in model_json_schema
return model_json_schema(
File "/app/venv/lib/python3.11/site-packages/pydantic/main.py", line 591, in model_json_schema
params_json_schema = base_model.model_json_schema()
File "/app/venv/lib/python3.11/site-packages/agentscope/tool/_utils.py", line 155, in _extract_input_schema
self.input_schema = _extract_input_schema(func)
File "/app/venv/lib/python3.11/site-packages/agentscope/tool/_adapters.py", line 82, in __init__
FunctionTool.__init__(self, func, **kwargs)
File "/app/venv/lib/python3.11/site-packages/qwenpaw/governance/tool_adapter.py", line 153, in _policy_tool_init
return real_cls(*args, **kwargs)
File "/app/venv/lib/python3.11/site-packages/qwenpaw/governance/tool_adapter.py", line 139, in __new__
PolicyGuardedTool(
File "/app/venv/lib/python3.11/site-packages/qwenpaw/app/workspace/local_workspace.py", line 90, in
return [
File "/app/venv/lib/python3.11/site-packages/qwenpaw/app/workspace/local_workspace.py", line 89, in list_tools
tools: list[Any] = await local_ws.list_tools(
File "/app/venv/lib/python3.11/site-packages/qwenpaw/runtime/builder.py", line 111, in build_toolkit
toolkit = await self.build_toolkit(
File "/app/venv/lib/python3.11/site-packages/qwenpaw/runtime/builder.py", line 388, in build
ctx.agent = await builder.build(ctx)
File "/app/venv/lib/python3.11/site-packages/qwenpaw/runtime/runtime.py", line 105, in run
async for item in rt.run(request):
File "/app/venv/lib/python3.11/site-packages/qwenpaw/app/workspace/workspace.py", line 329, in stream_query
async for event in self._process(request):
File "/app/venv/lib/python3.11/site-packages/qwenpaw/app/channels/console/channel.py", line 423, in stream_one
Additionally, the log shows warnings about the browser bridge not being ready, but those appear to be separate issues and may not be directly related.
Additional Notes
The error is triggered by the agentscope library when trying to extract the input schema for a function tool (likely the recall_history_python tool). Pydantic v2 requires model_rebuild() for dynamically created models, but the class is not fully defined (possibly because Optional is not imported or defined in the context).
A workaround might be to manually call model_rebuild() on the class, or to adjust the tool definition to avoid using dynamic Pydantic models that are not fully defined at the time of schema generation.
The error may be related to how agentscope handles tool functions that have type hints containing Optional or other forward references.
This issue may be reproducible in other channels that use the same tool registration logic.
Please forward this report to the development team. If additional information is needed, I can assist further.
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.