Skip to content

feat(agent-adapters): add diagnostic logging for raw error detection#467

Merged
jonwiggins merged 1 commit intojonwiggins:mainfrom
nethi:feat/agent-adapter-error-logging
Apr 21, 2026
Merged

feat(agent-adapters): add diagnostic logging for raw error detection#467
jonwiggins merged 1 commit intojonwiggins:mainfrom
nethi:feat/agent-adapter-error-logging

Conversation

@nethi
Copy link
Copy Markdown
Contributor

@nethi nethi commented Apr 20, 2026

Summary

Add console.warn logging when agent adapters detect raw text errors (authentication failures, API key issues, etc.) in non-JSON output. This improves debuggability by surfacing the actual error message in worker logs.

Motivation

During debugging of a Gemini agent failure, we discovered the actual error message "API key not valid" was being detected and stored but never logged. The root cause turned out to be a duplicated/corrupted API key in the secrets store. With this change, such errors are immediately visible in the worker logs, making diagnosis much faster.

Changes

  • Added diagnostic console.warn logging in the error detection path for all agent adapters that parse raw text errors:

    • Gemini
    • Codex
    • Copilot
    • OpenCode
    • OpenClaw
  • The logs use a consistent format: [adapter-name] Raw error: <error message>

  • Only triggered when isRawTextError() detects an authentication/API key/config error pattern

Testing

  • All agent-adapter tests pass (230/230)
  • The new logging appears in test stderr (expected and harmless - tests verify error detection works)
  • Manually tested with a Gemini task to confirm error logging works in production

Example

Before this change, a corrupted GEMINI_API_KEY would result in:

Task failed with: API key not valid

After this change, worker logs show:

[gemini] Raw error: Error: API key not valid. Please pass a valid API key.

This makes it immediately clear that the issue is with the API key itself, not network/quota/other issues.

Note on Test Failures

The CI shows 2 failing tests in apps/api (server.test.ts and openapi.test.ts). These are pre-existing failures on main branch (unrelated to this PR) - verified by running tests on main which shows the same 2 failures.

@jonwiggins
Copy link
Copy Markdown
Owner

The actual new change here — a console.warn in each adapter's raw-error path — is tiny and useful for diagnosing auth/API-key failures. Happy to take it.

But the branch can't be reviewed as-is. It shares the same 12 contaminating commits as #466 (copies of #462/#463/#464, three Merge upstream/main, and the same set of drive-by changes: repo-service.ts, ticket-sync-service.ts, github-token.ts, setup.ts, vitest.config.ts, review-service.test.ts, setup-local.sh). The real diff for this PR is ~6 lines across 5 adapter files, buried inside 18 changed files.

Could you rebase onto fresh main so only the adapter console.warn additions remain? #461/#462/#463 have merged, so much of the noise will disappear automatically. The drive-bys should become their own PRs (see my note on #466) — let's keep each PR to one logical change.

Minor nit once rebased: consider downgrading console.warnconsole.error for consistency with the hasError = true semantics, or using the existing logger if the adapters have one in scope.

@nethi
Copy link
Copy Markdown
Contributor Author

nethi commented Apr 20, 2026

will do. thanks

Add console.warn logging when agent adapters detect raw text errors
(authentication failures, API key issues, etc.) in non-JSON output.
This improves debuggability by surfacing the actual error message in
worker logs, making it easier to diagnose configuration issues like
invalid/corrupted API keys.

Affected adapters: Gemini, Codex, Copilot, OpenCode, OpenClaw

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@nethi nethi force-pushed the feat/agent-adapter-error-logging branch from 13bdf45 to c772eea Compare April 20, 2026 18:03
@jonwiggins jonwiggins merged commit e5ce8fd into jonwiggins:main Apr 21, 2026
7 checks passed
jplorier pushed a commit to jplorier/optio that referenced this pull request May 5, 2026
…onwiggins#467)

Add console.warn logging when agent adapters detect raw text errors
(authentication failures, API key issues, etc.) in non-JSON output.
This improves debuggability by surfacing the actual error message in
worker logs, making it easier to diagnose configuration issues like
invalid/corrupted API keys.

Affected adapters: Gemini, Codex, Copilot, OpenCode, OpenClaw

Co-authored-by: Ramesh Nethi <r.nethi@gogatewayai.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
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.

2 participants