Skip to content

Log OpenAI OAuth error responses - #96

Open
k2v7n24cbf-cyber wants to merge 1 commit into
sandydasari:mainfrom
k2v7n24cbf-cyber:agent/openai-oauth-subagent-model
Open

Log OpenAI OAuth error responses#96
k2v7n24cbf-cyber wants to merge 1 commit into
sandydasari:mainfrom
k2v7n24cbf-cyber:agent/openai-oauth-subagent-model

Conversation

@k2v7n24cbf-cyber

@k2v7n24cbf-cyber k2v7n24cbf-cyber commented Jul 16, 2026

Copy link
Copy Markdown

Log OpenAI OAuth error responses

Summary

This PR is intentionally logging-only.

  • Adds warning logs for final non-2xx responses from the OpenAI OAuth / ChatGPT Codex backend fetch path.
  • Logs the upstream response body, status, status text, request URL, and selected diagnostic request-id headers.
  • Reads the body from Response.clone(), so the original response is still returned unchanged to the AI SDK.
  • Does not change model selection.
  • Does not change generateObject() usage.
  • Does not add a generateText() fallback.
  • Does not change title generation, memory selection, parsing, validation, retries, or provider routing behavior.

Reason / RCA

In a live OpenAcme deployment using OpenAI ChatGPT OAuth, auxiliary helper calls such as title generation and memory selection were failing with only:

Bad Request

The existing logs showed the failing requests were going through the ChatGPT OAuth / Codex backend path, but they did not preserve the upstream OpenAI error response body. Because of that, we could not determine the actual rejected field or backend validation reason.

The objective of this PR is only to expose the missing evidence. It does not attempt to fix or work around the failure.

Implementation Notes

The OpenAI OAuth fetch wrapper in packages/llm-provider/src/registry.ts now calls a logging helper after the final response is available, including after the existing 401 refresh-and-retry path.

For any final non-2xx response, it logs:

  • provider: "openai"
  • auth: "oauth"
  • request URL
  • HTTP status and status text
  • selected diagnostic headers:
    • cf-ray
    • openai-processing-ms
    • x-openai-request-id
    • x-request-id
    • x-stainless-request-id
  • response body, truncated at 4000 characters

It does not log authorization headers or request bodies.

Validation

  • pnpm --filter @openacme/config build
  • pnpm --filter @openacme/auth build
  • pnpm --filter @openacme/llm-provider check-types
  • pnpm --filter @openacme/llm-provider test -- subagent-model.test.ts
  • pnpm --filter @openacme/llm-provider build
  • Push hook passed:
    • full pnpm build
    • server e2e: 13 files / 26 tests passed

@k2v7n24cbf-cyber k2v7n24cbf-cyber changed the title Keep OpenAI OAuth auxiliary jobs on configured model Handle OpenAI OAuth auxiliary helper calls Jul 20, 2026
@k2v7n24cbf-cyber
k2v7n24cbf-cyber force-pushed the agent/openai-oauth-subagent-model branch from f2d5a97 to 3d2e7ab Compare July 20, 2026 07:20
@k2v7n24cbf-cyber
k2v7n24cbf-cyber force-pushed the agent/openai-oauth-subagent-model branch from 3d2e7ab to 48c7d84 Compare July 20, 2026 07:28
@k2v7n24cbf-cyber k2v7n24cbf-cyber changed the title Handle OpenAI OAuth auxiliary helper calls Log OpenAI OAuth error responses Jul 20, 2026
@k2v7n24cbf-cyber
k2v7n24cbf-cyber marked this pull request as ready for review July 20, 2026 08:36
k2v7n24cbf-cyber added a commit to k2v7n24cbf-cyber/openacme that referenced this pull request Jul 22, 2026
Merge staged copy of sandydasari#96 into local-stage.
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