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
|
||||
|
||||
@@ -27,6 +27,7 @@ def test_agent_section_defaults(tmp_path: Path) -> None:
|
||||
assert store.agent_config.confirm_destructive is True
|
||||
assert store.agent_config.path_denylist == []
|
||||
assert store.agent_config.allow_paths == {}
|
||||
assert store.agent_config.auto_continue_limits is False
|
||||
assert store.agent_config.max_context_tokens == 200_000
|
||||
assert store.plugins_config.enable == []
|
||||
assert store.plugins_config.disable == []
|
||||
@@ -83,6 +84,7 @@ parallel_tools = false
|
||||
confirm_destructive = false
|
||||
path_denylist = ["/secrets/", ".ssh/"]
|
||||
max_context_tokens = 5000
|
||||
auto_continue_limits = true
|
||||
""",
|
||||
encoding="utf-8",
|
||||
)
|
||||
@@ -94,6 +96,7 @@ max_context_tokens = 5000
|
||||
assert store.agent_config.confirm_destructive is False
|
||||
assert store.agent_config.path_denylist == ["/secrets/", ".ssh/"]
|
||||
assert store.agent_config.max_context_tokens == 5000
|
||||
assert store.agent_config.auto_continue_limits is True
|
||||
composed = compose_agent_system_content(
|
||||
store.agent_config.system_prompt,
|
||||
store.agent_config.tool_directives,
|
||||
|
||||
Reference in New Issue
Block a user