mirror of
https://github.com/NCBM/plyngent.git
synced 2026-11-07 15:37:55 +08:00
cli/config: --auto-continue flag and [agent] auto_continue_limits
This commit is contained in:
@@ -80,6 +80,16 @@ def test_prompt_continue_limit_noninteractive_denies() -> None:
|
||||
assert prompt_continue_limit("limit") is False
|
||||
|
||||
|
||||
def test_setup_hooks_installs_pty_hook_for_auto_continue(clean_auto_continue: None) -> None:
|
||||
del clean_auto_continue
|
||||
from plyngent.cli.app import _setup_hooks
|
||||
|
||||
_setup_hooks(interactive=False, auto_continue=True)
|
||||
assert PtyManager._limit_continue is not None
|
||||
_setup_hooks(interactive=False, auto_continue=False)
|
||||
assert PtyManager._limit_continue is None
|
||||
|
||||
|
||||
def test_pty_offer_raise_uses_auto_continue(clean_auto_continue: None) -> None:
|
||||
del clean_auto_continue
|
||||
PtyManager.set_limit_continue_hook(prompt_continue_limit)
|
||||
|
||||
@@ -94,6 +94,32 @@ async def test_help_and_clear(state: ReplState) -> None:
|
||||
assert state.agent.messages == []
|
||||
|
||||
|
||||
async def test_auto_continue_limits_installs_on_limit(tmp_path: Path) -> None:
|
||||
from plyngent.cli.limits import auto_continue_enabled, reset_auto_continue
|
||||
|
||||
memory = await MemoryStore.open(DatabaseConfig())
|
||||
provider = OpenAIProvider(access_key_or_token="sk-test")
|
||||
config = ConfigStore(path=tmp_path / "plyngent.toml", document=tomlkit.document())
|
||||
config.providers = {"local": provider}
|
||||
try:
|
||||
st = ReplState(
|
||||
config=config,
|
||||
memory=memory,
|
||||
workspace=tmp_path,
|
||||
provider_name="local",
|
||||
provider=provider,
|
||||
model="gpt-test",
|
||||
tools_enabled=False,
|
||||
interactive_limits=False,
|
||||
auto_continue_limits=True,
|
||||
)
|
||||
assert auto_continue_enabled() is True
|
||||
assert st.agent.on_limit is not None
|
||||
finally:
|
||||
reset_auto_continue()
|
||||
await memory.close()
|
||||
|
||||
|
||||
async def test_help_command_usage_line(state: ReplState, capsys: pytest.CaptureFixture[str]) -> None:
|
||||
assert await handle_slash(state, "/help compact") is True
|
||||
out = capsys.readouterr().out
|
||||
|
||||
Reference in New Issue
Block a user