Skip to content

Conversation

@agustif
Copy link
Owner

@agustif agustif commented Dec 11, 2025

Summary

Adds optional health check infrastructure for providers to validate connection availability before SDK initialization.

Changes

  • ✅ Add healthCheck config schema with url, timeout, and enabled options
  • ✅ Implement checkProviderHealth function using AbortSignal.timeout
  • ✅ Integrate health check into getSDK (lazy, non-blocking, cached)
  • ✅ Add HealthCheckError for health check failures
  • ✅ Update error formatting for health check errors
  • ✅ Add health check result caching in provider state

Behavior

  • Health checks are automatically enabled for local providers (127.0.0.1 or localhost)
  • Health checks can be explicitly configured for any provider via config
  • Health checks are lazy - only run when SDK is first requested
  • Health checks are non-blocking - failures log warnings but don't prevent SDK creation
  • Health check results are cached per provider to avoid repeated checks

Example Config

{
  "provider": {
    "lmstudio": {
      "healthCheck": {
        "url": "http://127.0.0.1:1234/v1/models",
        "timeout": 2000,
        "enabled": true
      }
    }
  }
}

Testing

  • Health check passes when server is online
  • Health check fails gracefully when server is offline
  • Health check respects timeout
  • Health check doesn't block provider initialization
  • Health check results are cached
  • Local providers automatically get health checks

Related

Part of LM Studio support improvements. See packages/opencode/docs/LM_STUDIO_DEEP_REVIEW.md for full context.

Add optional health check support for providers to validate connection
before SDK initialization. Health checks are lazy, non-blocking, and
cached per provider.

- Add healthCheck config schema with url, timeout, and enabled options
- Implement checkProviderHealth function with AbortSignal.timeout
- Integrate health check into getSDK (lazy, non-blocking)
- Add HealthCheckError for health check failures
- Add health check result caching in provider state
- Update error formatting for health check errors

Health checks are automatically enabled for local providers (127.0.0.1
or localhost) and can be explicitly configured for any provider via
config. Results are cached to avoid repeated checks.

Closes: #<issue-number>
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