Fix opencode-local adapter tests and behavior - #240
Conversation
- Move costUsd to top-level return field in parseOpenCodeJsonl (out of usage) - Fix session-not-found regex to match "Session not found" pattern - Use callID for toolUseId in UI stdout parser, add status/metadata header - Fix CLI formatter: separate tool_call/tool_result lines, split step_finish - Enable createIfMissing for cwd validation in environment tests - Add empty OPENAI_API_KEY override detection - Classify ProviderModelNotFoundError as warning during model discovery - Make model discovery best-effort when no model is configured Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Greptile SummaryThis PR fixes several bugs in the Key changes:
Issues found:
Confidence Score: 3/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[testEnvironment called] --> B{cwd exists?}
B -->|createIfMissing=true\nnow creates dir| C[opencode_cwd_valid ✅]
B -->|Error| D[opencode_cwd_invalid ❌]
C --> E{OPENAI_API_KEY override empty?}
E -->|Yes| F[opencode_openai_api_key_missing ⚠️]
E -->|No| G[Resolve command]
F --> G
G --> H{canRunProbe?}
H -->|No| I[Skip model discovery]
H -->|configuredModel set| J[discoverOpenCodeModels]
H -->|no configuredModel| K[discoverOpenCodeModels\nbest-effort]
J -->|success| L[opencode_models_discovered ✅]
J -->|ProviderModelNotFoundError| M[opencode_hello_probe_model_unavailable ⚠️]
J -->|other error| N[opencode_models_discovery_failed ❌]
K -->|success| O[opencode_models_discovered ✅]
K -->|ProviderModelNotFoundError| P[opencode_hello_probe_model_unavailable ⚠️]
K -->|other error| Q[🚫 silently dropped]
L --> R{configuredModel & canRunProbe?}
M --> R
R -->|Yes| S[ensureOpenCodeModelConfiguredAndAvailable]
S -->|success| T[modelValidationPassed=true]
S -->|fail| U[opencode_model_invalid ❌]
T --> V[Run hello probe]
V -->|timedOut| W[opencode_hello_probe_timed_out ⚠️]
V -->|exit=0 & no error| X{summary has 'hello'?}
V -->|ProviderModelNotFoundError| Y[opencode_hello_probe_model_unavailable ⚠️]
V -->|auth error| Z[opencode_hello_probe_auth_required ⚠️]
V -->|other fail| AA[opencode_hello_probe_failed ❌]
X -->|Yes| AB[opencode_hello_probe_passed ✅]
X -->|No| AC[opencode_hello_probe_unexpected_output ⚠️]
Last reviewed commit: 17058dd |
| } catch (err) { | ||
| const errMsg = err instanceof Error ? err.message : String(err); | ||
| if (/ProviderModelNotFoundError/i.test(errMsg)) { | ||
| checks.push({ | ||
| code: "opencode_hello_probe_model_unavailable", | ||
| level: "warn", | ||
| message: "The configured model was not found by the provider.", | ||
| detail: errMsg, | ||
| hint: "Run `opencode models` and choose an available provider/model ID.", | ||
| }); | ||
| } | ||
| } |
There was a problem hiding this comment.
Non-ProviderModelNotFoundError failures silently swallowed
When !configuredModel, errors from discoverOpenCodeModels that are not ProviderModelNotFoundError are silently discarded — no check is pushed at any level. This means authentication errors, binary-not-found errors, network failures, or any other unexpected errors during best-effort model discovery produce zero user-visible feedback. The user would see the environment test pass with no indication that something went wrong during model discovery.
At a minimum, unexpected errors here should be downgraded to a "warn" check rather than dropped entirely:
| } catch (err) { | |
| const errMsg = err instanceof Error ? err.message : String(err); | |
| if (/ProviderModelNotFoundError/i.test(errMsg)) { | |
| checks.push({ | |
| code: "opencode_hello_probe_model_unavailable", | |
| level: "warn", | |
| message: "The configured model was not found by the provider.", | |
| detail: errMsg, | |
| hint: "Run `opencode models` and choose an available provider/model ID.", | |
| }); | |
| } | |
| } | |
| } catch (err) { | |
| const errMsg = err instanceof Error ? err.message : String(err); | |
| if (/ProviderModelNotFoundError/i.test(errMsg)) { | |
| checks.push({ | |
| code: "opencode_hello_probe_model_unavailable", | |
| level: "warn", | |
| message: "The configured model was not found by the provider.", | |
| detail: errMsg, | |
| hint: "Run `opencode models` and choose an available provider/model ID.", | |
| }); | |
| } else { | |
| checks.push({ | |
| code: "opencode_models_discovery_failed", | |
| level: "warn", | |
| message: errMsg || "OpenCode model discovery failed (best-effort, no model configured).", | |
| hint: "Run `opencode models` manually to verify provider auth and config.", | |
| }); | |
| } | |
| } |
There was a problem hiding this comment.
Agreed — adopted your suggestion. Non-ProviderModelNotFoundError failures during best-effort model discovery now emit a warn-level opencode_models_discovery_failed check instead of being silently swallowed. Fixed in 672d769.
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
…allowed errors - Update cwd test to expect an error for missing directories (matches createIfMissing: false accepted from review) - Add warn-level check for non-ProviderModelNotFoundError failures during best-effort model discovery when no model is configured Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…apter-tests Fix opencode-local adapter tests and behavior
…apter-tests Fix opencode-local adapter tests and behavior
Summary
costUsdto top-level return field inparseOpenCodeJsonl(was incorrectly nested insideusage), and fix session-not-found regex that failed to match "Session not found" patternscallIDfortoolUseId(was usingpart.id), add status/metadata header to tool result contenttool_call/tool_resultlines, splitstep_finishinto reason and tokens lines, trim trailing whitespace from outputcreateIfMissingfor cwd validation, add emptyOPENAI_API_KEYoverride detection, classifyProviderModelNotFoundErroras warning during model discovery, make model discovery best-effort when no model is configuredTest plan
npm test)🤖 Generated with Claude Code