LLM facade drops opts.op before providers — per-op provider switches (e.g. thinking kill-switch for summarize) can never fire
Bug Description
Providers cannot apply per-operation (op) behavior because the op tag is dropped before it reaches the provider layer. opts.op is set by every caller (e.g. capture.summarize), but buildCallInput() in the LLM facade doesn't copy it into the input object handed to provider.complete(). Any per-op switch inside a provider (request-body tweaks, routing, budget overrides) therefore silently never fires.
This bit us in practice: OpenRouter's DeepSeek models burn the full token budget and double latency on capture.summarize because the recommended thinking: { type: "disabled" } can't be applied per-op — the condition opts.op === "capture.summarize" inside the provider always evaluates against an op that was never forwarded.
Affected code (2.0.17)
dist/core/llm/client.js:
function buildCallInput(opts, jsonMode) {
return {
temperature: opts?.temperature ?? config.temperature,
maxTokens: opts?.maxTokens ?? config.maxTokens ?? DEFAULT_MAX_TOKENS,
jsonMode,
stop: opts?.stop,
// <-- opts?.op is dropped here
};
}
Callers pass op only into logging/metrics paths (callWithFallback(messages, input, opts, op) → record(...)/facadeLog), not into the provider input.
Suggested fix
One line in buildCallInput:
stop: opts?.stop,
op: opts?.op,
Then per-op provider behavior works, e.g. in core/llm/providers/openai.js (both complete and stream request builders):
if (opts.op === "capture.summarize") {
body.thinking = { type: "disabled" }; // OpenRouter reasoning-model kill-switch
}
Longer-term it may be worth defining which ops are meaningful (capture.summarize, retrieval.filter, skill.evolve, …) and documenting them, so per-op switches don't depend on string matching scattered across providers.
Impact
Without this, summarize-style calls on reasoning models (DeepSeek R-series etc. via OpenRouter) cost ~2× latency and excess tokens on every capture. We verified locally on 2.0.17: with the one-liner + provider switch, summarize latency drops back to non-thinking levels and token usage falls accordingly.
Environment
- Plugin: @memtensor/memos-local-plugin 2.0.17
- Agent: Hermes (Windows native); LLM via OpenRouter-compatible endpoint
🤖 AutoDev has picked up this issue and started working on it.
Task ID: aca74652f3c40919
Working branch: bugfix/autodev-2308-20260829212023996
Target branch: latest dev* branch
Workflow: opsp (analysis → coding → testing → PR)
I will post the PR link here once done. If I need more information, I will ask in the comments.
✅ AutoDev task aca74652f3c40919 completed.
Summary: Fix #2308: the LLM facade in apps/memos-local-plugin/core/llm/client.ts no longer drops opts.op when it hands ProviderCallInput to provider.complete() / provider.stream(). Two-line change: extend ProviderCallInput in core/llm/types.ts with an optional op?: string, and copy opts?.op inside buildCallInput(). op stays optional so providers must not assume it is set; no public LlmClient surface change and no new error codes.
This unblocks the OpenRouter/DeepSeek reasoning kill-switch reported in the issue (opts.op === "capture.summarize" inside a provider's request builder can now actually evaluate true). Landing the per-op switch itself — e.g. body.thinking = { type: "disabled" } in providers/openai.ts — is a routing-policy decision left as a follow-up so operators can review it independently.
Tests: added 4 new unit tests under a new "op propagation (issue #2308)" describe block in tests/unit/llm/client.test.ts covering complete / completeJson / stream forwarding plus the "no op supplied" case. Verification: all 84 LLM unit tests green (5 files: client / providers / json-mode / prompts / fetcher), tsc -p tsconfig.json --noEmit clean. The 46 pre-existing failing test files in the broader unit suite (memory/l3/subscriber etc.) were verified unchanged against the base branch via git stash and are unrelated to this fix.
Confidence: 0.85 — root cause and fix were both explicit in the issue with local verification by the reporter.
Base branch: main
Branch: bugfix/autodev-2308-20260829212023996
Commit: 2ed904f
PR: https://github.com/MemTensor/MemOS/pull/2309
Assigned to: @Wang-Daoji
Reviewers: @whipser030, @hijzy
This issue has been automatically marked as stale due to inactivity.
This issue has been automatically closed due to inactivity.