Skip to content

fix: forward provider parameters during profile cleanup - #289

Open
amandeavor wants to merge 2 commits into
tickernelz:mainfrom
amandeavor:fix/cleanup-extra-params
Open

fix: forward provider parameters during profile cleanup#289
amandeavor wants to merge 2 commits into
tickernelz:mainfrom
amandeavor:fix/cleanup-extra-params

Conversation

@amandeavor

Copy link
Copy Markdown
Collaborator

Summary

Fixes #287.

The external profile-cleanup request now forwards configured memoryExtraParams through the same safe-parameter helper used by the other provider paths. Cleanup-critical fields are assigned afterward, so extra parameters cannot replace the model, messages, temperature, or required JSON response format.

Validation

  • bun test tests/ai-cleanup.test.ts: 8 passed
  • bun run typecheck: passed
  • production build: passed
  • plugin bundle and loader contracts: 10 passed
  • targeted Prettier check and git diff check: passed

The full Windows suite reached 437 passing tests. Two unrelated ONNX/vector tests timed out, and build-dependent tests initially failed before dist was generated; all 10 build-dependent tests passed after the production build.

Copilot AI lite review requested due to automatic review settings August 30, 2026 12:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@lindixu6-hash lindixu6-hash left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking edge case: this newly forwards arbitrary memoryExtraParams into the cleanup Chat Completions request, but applySafeExtraParams() does not protect stream. With memoryExtraParams: { stream: true }, the endpoint returns SSE while callViaExternalAPI() unconditionally calls response.json(), so cleanup deterministically fails. Please either add stream to the protected keys (preferred, since the existing provider consumers are also non-streaming) or force stream: false after applying extras, and add a regression assertion for this case. I locally verified the current head otherwise: targeted cleanup tests pass, full suite 447/447 passes with 1 skip, typecheck passes, and production build passes.

@amandeavor

Copy link
Copy Markdown
Collaborator Author

Added \stream\ to \PROTECTED_KEYS\ in \�pplySafeExtraParams\ so non-streaming endpoints across all providers and AI profile cleanup are protected from accidental SSE streaming injection.

Also added regression coverage:

  • In \ ests/ai-cleanup.test.ts, verified external API requests ignore \stream: true\ in \memoryExtraParams\ and keep \stream\ undefined.
  • In \ ests/ai-provider-config.test.ts, added unit tests for \�pplySafeExtraParams\ asserting protected keys (\stream, \model, \messages, \ ools, \ ool_choice, \ emperature, \input, \instructions, \conversation) cannot override core request structure.

Verified locally:

  • \�un test tests/ai-cleanup.test.ts tests/ai-provider-config.test.ts tests/minimax-provider.test.ts tests/anthropic-provider.test.ts tests/openai-chat-completion-provider.test.ts\ (55/55 passed)
  • \�un run typecheck\ (\ sc --noEmit\ passed cleanly)
  • Prettier formatting passed

@amandeavor

Copy link
Copy Markdown
Collaborator Author

Fixed the streaming edge case in the latest commit. stream is now protected centrally in �pplySafeExtraParams(), so it cannot put any of the existing non-streaming provider consumers into SSE mode. The cleanup regression fixture now passes stream: true and asserts that it is omitted from the final request body. Targeted cleanup tests pass (8/8), typecheck passes, and the production build passes. The full Windows suite reached 441 passing with 7 unrelated portability/worktree/SQLite timing failures.

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.

Forward memoryExtraParams in external AI cleanup requests

3 participants