fix: retry title generation without response_format on gateway 400 - #87508
honjiaxuan wants to merge 2 commits into
Conversation
fix: retry title generation without response_format on gateway 400
|
|
Thanks for the review — all three actionable points are addressed in new commit 313b981: 1. Retry condition narrowed. Now requires if (
"response_format" in err
and ("invalid_request_error" in err or "400" in err)
):An error that merely names 2. Prose-fallback test added. 3. Logged at WARNING. The fallback now logs: 4. Agreed — single retry, no risk of a storm (and the retry only fires on the 400/invalid_request_error signal, not on every failure). Full |
generate_title() sends a strict json_schema response_format with every
request. Some gateways (OpenCode Zen "Console Go") reject that payload
outright with HTTP 400 instead of ignoring it, so the parsing fallbacks
in _extract_title_text never get a chance and every new session ends up
untitled with an "Auxiliary title generation failed" warning.
Retry once without response_format when the error mentions
response_format or is an invalid_request_error. The prompt already
demands a {"title": ...} object, and _extract_title_text falls back
through a loose JSON scan, so the retry still produces a title.
Address review comments on NousResearch#87508: - Require 400/invalid_request_error alongside 'response_format' so an unrelated error that merely names response_format (e.g. unknown-parameter typo) re-raises instead of being papered over. - Log the fallback at WARNING so the gateway incompatibility is discoverable in default agent.log. - Add tests: prose (non-JSON) retry recovery, and non-retry on unrelated response_format mention. Co-authored-by: NousResearch/hermes-agent CI review
Duplicate of #82890: both implement the same single schema-free retry for HTTP 400 response_format/json_schema rejection in title generation. |
313b981 to
9d072aa
Compare
|
Note: the branch was rebased onto the latest upstream main (which now includes d516783, the answer-shaped auto-title guard) to resolve a merge conflict. The rebase kept both changes — my retry-without-response_format logic and upstream's answer-shaped guard coexist in |
Confirmed — Rebase coexisting with upstream answer-shaped guard confirmed. Good. |
|
Thanks @honjiaxuan for working on the gateway 400 on response_format. This landed on main through #89589 and #113966 (5cc8177), which covers the same symptom on the primary and fallback auxiliary paths and omits the field up front for providers known to reject it. Closing as superseded by the landed fix — the tracking issue (#83390 cluster) is closed with the same references. |
Problem
Session auto-titling fails with:
generate_title()sends a strictjson_schemaresponse_formaton every request. Some gateways — e.g. OpenCode Zen ("Console Go") — reject that payload outright with HTTP 400 instead of ignoring it. The parsing fallbacks in_extract_title_text(loose JSON scan / prose) never get a chance because the API call itself fails, so every new session ends up untitled and the user sees a warning banner.Fix
Retry once without
response_formatwhen the error message mentionsresponse_formator is aninvalid_request_error. The title prompt already demands a{"title": ...}object, and_extract_title_textfalls back through a loose JSON scan, so the retry still yields a proper title — verified end-to-end against the OpenCode Zen gateway (first call 400, retry 200, title produced).Non-response_format errors still propagate to the existing failure callback unchanged.
Tests
Added
test_retries_without_response_format_when_gateway_rejects_json_schema— first call rejects with the exact "Console Go" error, retry succeeds, title is parsed. Fulltests/agent/test_title_generator.pysuite passes (34 tests).