-
Notifications
You must be signed in to change notification settings - Fork 2.7k
feat: add API inference logging for debugging #10283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
+3,066
−220
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
All issues have been resolved. The latest commit (e5b9558) adds improved model extraction from payloads, fixes Headers cloning for SSE stream teeing, gates dotenv loading with existence checks, and removes unused code. LGTM!
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
14bae05 to
4b525dc
Compare
- Add ApiInferenceLogger singleton class for logging API requests/responses - Add inferenceLogger property to BaseProvider - Update all providers to use the logger - Configure logger in extension.ts with output channel sink - Add payload sanitization (truncate strings, cap arrays, redact secrets) - Enable via ROO_CODE_API_LOGGING=true environment variable Closes ROO-271
342ecf6 to
95c0030
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Enhancement
New feature or request
PR - Needs Review
size:XXL
This PR changes 1000+ lines, ignoring generated files.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements raw API inference request/response logging behind
ROO_CODE_API_LOGGING=trueand emits logs to the VS Code Debug Console viaconsole.log.What changed (vs the PR’s original direction)
The original approach was trending toward updating each provider’s business logic to manually log provider-specific request/response shapes.
This PR instead lands on a middleware-style transport interception approach where possible:
createLoggingFetch) that logs actual request bodies and response bodies at the SDKfetchboundary.fetchinto SDK clients at construction time (OpenAI-compatible + Anthropic SDK), avoiding per-provider stream reassembly.text/event-streamresponses, the wrapper tees the stream so the SDK can consume it normally while we buffer/log the other branch.__sse.__rawSse).For providers that don’t expose
fetchinjection or don’t use SSE/HTTP in an interceptable way, we fall back to provider-level logging at the API boundary.Log format
[API][request][Provider][model]+ sanitized payload[API][response][Provider][model][Xms](+[streaming]) + sanitized payload[API][error][Provider][model][Xms]+ sanitized payloadPayloads are sanitized (redaction, truncation, base64 image replacement) before logging.
Provider coverage
Covered via HTTP middleware (
createLoggingFetch)BaseOpenAiCompatibleProviderderivatives)fetchprovider: CerebrasCovered via provider-level logging (special transports)
ollamanpm client)@anthropic-ai/vertex-sdk)Tests
Adds/updates unit tests to validate:
createLoggingFetch(SSE + non-SSE logging behavior)Important
Adds API inference logging for debugging, using middleware-style transport interception to log requests and responses across various providers, with structured logging to the VS Code Debug Console.
ROO_CODE_API_LOGGING=true, logging to VS Code Debug Console.createLoggingFetchfor HTTP request/response logging.ApiInferenceLoggerfor structured logging of requests, responses, and errors.createLoggingFetchandApiInferenceLogger.This description was created by
for e5b9558. You can customize this summary. It will automatically update as commits are pushed.