Skip to content

ga: diagnose blank LLM responses; tui keeps [Warn]/[Error] labels - #819

Open
louisss1016 wants to merge 1 commit into
lsdefine:mainfrom
louisss1016:fix/issue-815-blank-response-diagnostics
Open

louisss1016 wants to merge 1 commit into
lsdefine:mainfrom
louisss1016:fix/issue-815-blank-response-diagnostics

Conversation

@louisss1016

Copy link
Copy Markdown

Addresses #815.

What

Blank responses — observed with third-party relays that return an HTTP-successful but whitespace-only payload — used to produce a single opaque line with nothing to attribute the failure to. This PR adds a redacted diagnostic and keeps severity visible in the TUI, without touching the retry semantics from #201.

Changes

ga.py

  • describe_blank_response() — pure, module-level helper producing a compact one-liner: whitespace_only vs empty_payload classification, len(content)/len(thinking), deduped+sorted response block types (extracted from response.raw), and, when a backend is reachable, model= and host=.
  • _url_host() — hostname-only extraction (no userinfo, no port, no credentials); returns unknown for garbage input instead of raising, since a diagnostic must never crash the retry path.
  • do_no_tool() — retry logic untouched (still 3 attempts, then exit). The warning line now carries the attempt counter and the diagnostic:
    [Warn] Empty LLM response (1/3); retrying [kind=whitespace_only len(content)=1 len(thinking)=0 blocks=text model=gpt-4o host=api.openai.com]

frontends/tui_v3.py

  • _ACTION_RE split into _ACTION_RE (Action|Status|Info|Debug) + _SEVERITY_RE (Warn|Warning|Error). Non-severity tags still collapse to · , but severity tags now render as · [Warn] … — issue suggestion timeout to any question #3.

Tests

  • frontends/tests/test_blank_response_diagnostics.py — 15 tests following the repo's ast/exec extraction pattern (ga.py/tui_v3.py have heavy import side effects): classification, credential redaction (user:s3cret@ never appears), host edge cases, regex disjointness, and the exact rendering contract from the issue.

Verification

  • python -m pytest frontends/tests -q → 287 passed; the 3 failures (test_data_backup symlink ×2, test_release_qualification) are pre-existing on Windows without developer mode / without a built package — identical before and after this change.
  • Diff verified against a fresh tarball of f308ee7e: only the 4 hunks above plus the new test file.

Scope notes

…define#815)

Blank responses (observed with third-party relays returning whitespace-only
successful payloads) now emit a redacted one-liner alongside the unchanged
3-attempt retry: kind, content/thinking sizes, response block types, model
and gateway host (hostname only, never credentials).

The TUI splits _ACTION_RE so [Action]/[Status]/[Info]/[Debug] still collapse
to a neutral bullet while [Warn]/[Warning]/[Error] render as `· [Warn]` —
severity stays visible.

Adds 15 tests via the repo's ast/exec extraction pattern; full suite
287 passed (3 pre-existing Windows-env failures unrelated).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant