fix(completion): remove /model <arg> autocomplete from CLI/TUI (#39727)
* fix: respect disabled auto-compaction on context overflow Port from anomalyco/opencode#30749. When compression.enabled is false, NO automatic compaction trigger may fire. The proactive token-threshold paths (preflight + post-response should_compress gate) already honoured the setting, but the three provider-overflow recovery paths in the agent loop — long-context-tier 429, 413 payload-too-large, and context-overflow — called _compress_context() unconditionally, silently compressing and rotating the session against the user's explicit choice. Add a single guard at the top of the overflow-recovery dispatch: when compression is disabled and the error is one of those three overflow classes, surface a terminal error (compaction_disabled: True) telling the user to /compress manually, /new, switch to a larger-context model, or reduce attachments. Manual /compress (force=True) is unaffected — it never enters this loop. Tests: new TestOverflowWithCompactionDisabled (413 + 400 overflow don't compress when disabled; control case still compresses when enabled). Existing overflow-recovery tests updated to enable compaction explicitly (they verify the recovery fires); fixture defaults flipped to True to match production (compression.enabled defaults to True). * fix(completion): remove /model <arg> autocomplete from CLI/TUI The TUI frontend already suppressed /model argument completion in favor of the two-step ModelPicker (useCompletion.ts), but the CLI prompt_toolkit completer and the gateway-backed complete.slash RPC (TUI + desktop) still emitted model aliases and probed LM Studio on every keystroke. Drops the /model branch in SlashCommandCompleter.get_completions, the _model_completions method, and the LM Studio probe/cache helper that only fed it. Command-name completion (/mod -> model) and sibling arg completers (/skin, /personality) are untouched. Removes the now-dead TestModelTabCompletion tests.
This commit is contained in:
parent
14fee4f112
commit
7583aedacd
2 changed files with 1 additions and 151 deletions
|
|
@ -178,72 +178,6 @@ class TestModelSwitchPersistence:
|
|||
assert result.base_url == "https://api.anthropic.com"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# /model tab completion
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
class TestModelTabCompletion:
|
||||
"""SlashCommandCompleter provides model alias completions for /model."""
|
||||
|
||||
def test_model_completions_yields_direct_aliases(self, monkeypatch):
|
||||
"""_model_completions yields direct aliases with model and provider info."""
|
||||
from hermes_cli.commands import SlashCommandCompleter
|
||||
from hermes_cli.model_switch import DirectAlias
|
||||
import hermes_cli.model_switch as ms
|
||||
|
||||
test_aliases = {
|
||||
"opus": DirectAlias("claude-opus-4-6", "anthropic", ""),
|
||||
"qwen": DirectAlias("qwen3.5:397b", "custom", "https://ollama.com/v1"),
|
||||
}
|
||||
monkeypatch.setattr(ms, "DIRECT_ALIASES", test_aliases)
|
||||
|
||||
completer = SlashCommandCompleter()
|
||||
completions = list(completer._model_completions("", ""))
|
||||
|
||||
names = [c.text for c in completions]
|
||||
assert "opus" in names
|
||||
assert "qwen" in names
|
||||
|
||||
def test_model_completions_filters_by_prefix(self, monkeypatch):
|
||||
"""Completions filter by typed prefix."""
|
||||
from hermes_cli.commands import SlashCommandCompleter
|
||||
from hermes_cli.model_switch import DirectAlias
|
||||
import hermes_cli.model_switch as ms
|
||||
|
||||
test_aliases = {
|
||||
"opus": DirectAlias("claude-opus-4-6", "anthropic", ""),
|
||||
"qwen": DirectAlias("qwen3.5:397b", "custom", "https://ollama.com/v1"),
|
||||
}
|
||||
monkeypatch.setattr(ms, "DIRECT_ALIASES", test_aliases)
|
||||
|
||||
completer = SlashCommandCompleter()
|
||||
completions = list(completer._model_completions("o", "o"))
|
||||
|
||||
names = [c.text for c in completions]
|
||||
assert "opus" in names
|
||||
assert "qwen" not in names
|
||||
|
||||
def test_model_completions_shows_metadata(self, monkeypatch):
|
||||
"""Completions include model name and provider in display_meta."""
|
||||
from hermes_cli.commands import SlashCommandCompleter
|
||||
from hermes_cli.model_switch import DirectAlias
|
||||
import hermes_cli.model_switch as ms
|
||||
|
||||
test_aliases = {
|
||||
"glm": DirectAlias("glm-4.7", "custom", "https://ollama.com/v1"),
|
||||
}
|
||||
monkeypatch.setattr(ms, "DIRECT_ALIASES", test_aliases)
|
||||
|
||||
completer = SlashCommandCompleter()
|
||||
completions = list(completer._model_completions("g", "g"))
|
||||
|
||||
assert len(completions) >= 1
|
||||
glm_comp = [c for c in completions if c.text == "glm"][0]
|
||||
meta_str = str(glm_comp.display_meta)
|
||||
assert "glm-4.7" in meta_str
|
||||
assert "custom" in meta_str
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Fallback base_url passthrough
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue