You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE]: Log LLM API request/response body at DEBUG log level #29186
I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Problem
Currently --log-level DEBUG produces no useful output for debugging LLM API calls. Across the entire codebase there are only 21 log.debug() calls (mostly config loading and TUI audio), and none of them cover the LLM request body sent to providers.
When troubleshooting issues like provider errors, malformed requests, or unexpected model behavior, there's no way to inspect what opencode actually sends to the API.
Comparison
Claude Code has --debug "api" which logs API-level request/response details. This is essential for debugging custom providers and understanding model failures.
Proposed Solution
Add log.debug() calls at the session/llm.ts level, after LLMRequestPrep.prepare() returns the prepared request. At minimum, log:
response headers/status on error
Ideally also log at the HTTP layer (e.g. via a custom fetch wrapper in provider.ts) to capture the raw JSON body sent to the provider endpoint.
Affected Files
packages/opencode/src/session/llm.ts — where streamText() is called
packages/opencode/src/session/llm/request.ts — where request is assembled
packages/opencode/src/provider/provider.ts — where provider SDKs are created
Reacted by BrettB, webgoto, bornmw, JohnnyEch0, Philipp Oeschger and amellouli-mgmtp
this works for me #32381
have to add "experimental": { "log_messages": "trace" } to ~/.opencode/opencode.json and add env variable OPENCODE_LOG_LEVEL=DEBUG, or start opencode with OPENCODE_LOG_LEVEL=DEBUG opencode
Activity
webgoto commentedon Jun 14, 2026
I really want this feature too!
bornmw commentedon Jun 15, 2026
this works for me #32381
have to add
"experimental": { "log_messages": "trace" }to~/.opencode/opencode.jsonand add env variableOPENCODE_LOG_LEVEL=DEBUG, or start opencode withOPENCODE_LOG_LEVEL=DEBUG opencodelakechain commentedon Jul 17, 2026
I really want this feature too!
neriousy commentedon Oct 22, 2026
Closing as stale