Skip to content

Agnes 模型 response协议报错 #1485

Closed

Description

@Walden-X

response协议好像会自动注入"tool_choice":"auto"
导致报错:
状态:不可用 (invalid_request)
消息:供应商 不可用:无效请求 (400)
延迟: 146ms
HTTP 状态: 400
请求 URL: https://api.agnes-ai.cn/v1/responses
响应: ***.BadRequestError: OpenAIException - {"error":{"message":"all: Invalid value for 'tool_choice': 'tool_choice' is only allowed when 'tools' are specified.","type":"invalid_request_error","code":4...
测试时间: 2026-09-16 16:00:39
验证详情:
HTTP 检查: ✗ 失败
延迟检查: ✓ 通过
内容验证: ✗ 失败

Activity

  1. github-actions commented on Sep 16, 2026

    @github-actions
    Contributor

    Thank you for reporting this issue.

    Analysis:

    Based on my investigation of the codebase, I've identified the root cause of this error. The problem is in the provider testing templates used for the /v1/responses endpoint.

    Affected code:

    The test templates that probe the /v1/responses endpoint contain an invalid combination of parameters:

    • src/lib/provider-testing/data/cx_codex_basic.json (lines 16-17)
    • src/lib/provider-testing/data/cx_gpt_basic.json (lines 16-17)

    Both files include:

    "tools": [],
    "tool_choice": "auto"

    Why this causes the error:

    According to the OpenAI Responses API specification, tool_choice should only be present when tools contains actual tool definitions. When tools is an empty array, including tool_choice violates the API contract, causing Agnes (and other strict OpenAI-compatible providers) to correctly reject the request with:

    Invalid value for 'tool_choice': 'tool_choice' is only allowed when 'tools' are specified.

    Comparison:

    The OpenAI Chat Completions test templates (oa_chat_basic.json and oa_chat_stream.json) do NOT include tool_choice and work correctly. This confirms that the issue is specific to the Responses API test templates.

    Workaround:

    Until this is fixed, you can work around the issue by using a custom test payload that omits tool_choice when no tools are specified, or by testing Agnes as an openai-compatible provider type using the /v1/chat/completions endpoint if supported.

    Related files:

    • src/lib/provider-testing/utils/test-prompts.ts (line 59) - also contains the same pattern in the fallback template
    • src/lib/provider-testing/data/cx_base.json (lines 12-13) - same issue

    Automated response from Claude AI

  2. github-actions commented on Oct 16, 2026

    @github-actions
    Contributor

    This issue has been automatically marked as stale because it has not had any activity in the last 30 days.

    If this issue is still relevant:

    • Please comment to keep it open
    • Add any new information that might help resolve it

    This issue will be automatically closed in 14 days if there is no further activity.

  3. github-actions commented on Oct 31, 2026

    @github-actions
    Contributor

    This issue has been automatically closed due to inactivity.

    If you believe this issue is still relevant, please feel free to reopen it with additional information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:providerbugSomething isn't workingstaleIssue has had no activity for 30+ days

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions