Skip to content

Comments

fix(providers): harden OpenAI/OpenRouter requests (SDK migration, ProviderParams filtering, streaming cleanup)#20

Merged
assagman merged 5 commits intomainfrom
improve/providers
Dec 16, 2025
Merged

fix(providers): harden OpenAI/OpenRouter requests (SDK migration, ProviderParams filtering, streaming cleanup)#20
assagman merged 5 commits intomainfrom
improve/providers

Conversation

@assagman
Copy link
Owner

@assagman assagman commented Dec 16, 2025

pivoting from no-package policy to using providers packages


Summary

  • Migrates OpenAI/OpenRouter providers to the official OpenAI Go SDK, reducing hand-rolled HTTP/parsing surface area and aligning request semantics with upstream.
  • Improves provider-specific request passthrough via ProviderParams:
    • centralizes filtering/allow-listing of provider params to avoid leaking unsupported fields
    • refines tool_choice + provider param handling for more predictable tool calling behavior
  • Fixes multiple robustness edge cases in provider I/O:
    • ensures streaming HTTP responses are closed to prevent resource leaks
    • sanitizes/normalizes tool call IDs to meet provider constraints
    • stabilizes cache / deterministic behavior by hashing toolcall/message fallbacks where needed
  • Updates examples (notably examples/project_review) to demonstrate:
    • ProviderParams usage (e.g., reasoning.effort=high)
    • improved cost formatting output
  • Adds dedicated tests for provider param filtering utilities.

Notes / Developer Impact

  • Introduces a new dependency: github.com/openai/openai-go/v3 (and its indirect deps), reflected in root + example go.mod/go.sum.
  • Removes an OpenRouter error handling test file as part of the refactor/restructure.

- Switch both providers to openai-go/v3 for generate + streaming
- Sanitize tool_call_id to meet strict provider constraints (40 chars, a-zA-Z0-9_-) with deterministic hashing
- Update/cleanup provider tests and add go.sum files for root + examples

Signed-off-by: assagman <ahmetsercansagman@gmail.com>
- allow extra provider-specific params (e.g. reasoning.effort, top_k, seed) without overriding DSGo-managed fields
- sanitize empty tool call IDs deterministically
- add provider param coverage in LM tests
- update project_review example with optional high-effort synthesis stage and consistent cost logging

Signed-off-by: assagman <ahmetsercansagman@gmail.com>
…arams filtering

Signed-off-by: assagman <ahmetsercansagman@gmail.com>
and apply BaseURL override in OpenRouter stream

Signed-off-by: assagman <ahmetsercansagman@gmail.com>
…ider param handling

Signed-off-by: assagman <ahmetsercansagman@gmail.com>
@assagman assagman self-assigned this Dec 16, 2025
@assagman assagman changed the title improve providers fix(providers): harden OpenAI/OpenRouter requests (SDK migration, ProviderParams filtering, streaming cleanup) Dec 16, 2025
@assagman assagman merged commit 62e4055 into main Dec 16, 2025
4 checks passed
@assagman assagman deleted the improve/providers branch December 16, 2025 10:19
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