langstage-cli 0.6.49__tar.gz → 0.6.50__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. {langstage_cli-0.6.49/langstage_cli.egg-info → langstage_cli-0.6.50}/PKG-INFO +2 -2
  2. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/README.md +1 -1
  3. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/langstage_cli/cli.py +39 -15
  4. {langstage_cli-0.6.49 → langstage_cli-0.6.50/langstage_cli.egg-info}/PKG-INFO +2 -2
  5. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/langstage_cli.egg-info/SOURCES.txt +1 -0
  6. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/pyproject.toml +1 -1
  7. langstage_cli-0.6.50/tests/test_menu_allowed_197.py +184 -0
  8. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/LICENSE +0 -0
  9. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/deepagent_code/__init__.py +0 -0
  10. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/langstage_cli/__init__.py +0 -0
  11. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/langstage_cli/agui_stream.py +0 -0
  12. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/langstage_cli/config.py +0 -0
  13. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/langstage_cli/exit_codes.py +0 -0
  14. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/langstage_cli/sessions.py +0 -0
  15. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/langstage_cli.egg-info/dependency_links.txt +0 -0
  16. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/langstage_cli.egg-info/entry_points.txt +0 -0
  17. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/langstage_cli.egg-info/requires.txt +0 -0
  18. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/langstage_cli.egg-info/top_level.txt +0 -0
  19. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/setup.cfg +0 -0
  20. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_advertised_wave4.py +0 -0
  21. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_agui_stream.py +0 -0
  22. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_approval_menu_abort.py +0 -0
  23. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_async_mode.py +0 -0
  24. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_checkpointer.py +0 -0
  25. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_cli.py +0 -0
  26. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_cli_help.py +0 -0
  27. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_codeconfig.py +0 -0
  28. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_config.py +0 -0
  29. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_config_command.py +0 -0
  30. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_configurable.py +0 -0
  31. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_ctrl_c_sync_tool.py +0 -0
  32. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_custom_decision_195.py +0 -0
  33. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_deferred_pass.py +0 -0
  34. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_dumb_term.py +0 -0
  35. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_exit_codes.py +0 -0
  36. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_generic_interrupt.py +0 -0
  37. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_help_render.py +0 -0
  38. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_hidden_option_suggestions.py +0 -0
  39. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_history_persist.py +0 -0
  40. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_hitl_approval_preview.py +0 -0
  41. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_hitl_resume_warning.py +0 -0
  42. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_init.py +0 -0
  43. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_interrupt_non_tty.py +0 -0
  44. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_legacy_config_home.py +0 -0
  45. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_load_error.py +0 -0
  46. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_message_boundaries.py +0 -0
  47. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_no_color.py +0 -0
  48. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_no_interactive_approve.py +0 -0
  49. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_no_persist_resume.py +0 -0
  50. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_paused_session_message.py +0 -0
  51. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_persist_env.py +0 -0
  52. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_quiet_output.py +0 -0
  53. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_reasoning_render.py +0 -0
  54. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_rename_shim.py +0 -0
  55. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_render_markdown.py +0 -0
  56. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_routine_1024.py +0 -0
  57. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_session_lifecycle.py +0 -0
  58. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_sessions.py +0 -0
  59. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_show_config.py +0 -0
  60. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_show_config_malformed.py +0 -0
  61. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_spec_loading_core.py +0 -0
  62. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_spec_resolution.py +0 -0
  63. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_spinner_reply_survives.py +0 -0
  64. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_stdin_interactive.py +0 -0
  65. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_stdin_single_shot.py +0 -0
  66. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_stream_mode.py +0 -0
  67. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_streaming_marker.py +0 -0
  68. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_terminal_width.py +0 -0
  69. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_toml_relative_paths.py +0 -0
  70. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_tool_card_args.py +0 -0
  71. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_tool_output_escape.py +0 -0
  72. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_turn_error_verbose.py +0 -0
  73. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_turn_exit_and_render.py +0 -0
  74. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_unicode_console.py +0 -0
  75. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_usage_hint_186.py +0 -0
  76. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_verbose_command.py +0 -0
  77. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_verify_flag.py +0 -0
  78. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_workspace.py +0 -0
  79. {langstage_cli-0.6.49 → langstage_cli-0.6.50}/tests/test_wrong_type_graph.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langstage-cli
3
- Version: 0.6.49
3
+ Version: 0.6.50
4
4
  Summary: The terminal stage for your LangGraph agent — Claude Code-style CLI for any CompiledGraph
5
5
  Author-email: Kedar Dabhadkar <kdabhadk@gmail.com>
6
6
  License-Expression: MIT
@@ -342,7 +342,7 @@ approval menu you answer by typing a number.
342
342
  |---|---|
343
343
  | `0` | success: the turn completed, `--verify` passed, `init` wrote its files |
344
344
  | `1` | failure: no agent configured, the agent failed to load, the turn errored or produced nothing, `--verify` failed, `--resume` found no session, `init` refused to overwrite |
345
- | `2` | paused on a human-in-the-loop interrupt: an approval is needed but stdin is not a terminal, or you left the approval prompt with **Exit** or Ctrl-C. `--no-interactive` auto-approves instead |
345
+ | `2` | paused on a human-in-the-loop interrupt: an approval is needed but stdin is not a terminal, or you left the approval prompt with **Exit** or Ctrl-C. `--no-interactive` auto-approves instead, unless the pending action doesn't allow approve, which also exits `2` |
346
346
  | `64` | usage error: an unknown option or bad value, `--demo` with `-a`, `--continue` with `--resume`, `MESSAGE` with `-f`, an empty `MESSAGE` |
347
347
 
348
348
  ## Creating Your Own Agent
@@ -304,7 +304,7 @@ approval menu you answer by typing a number.
304
304
  |---|---|
305
305
  | `0` | success: the turn completed, `--verify` passed, `init` wrote its files |
306
306
  | `1` | failure: no agent configured, the agent failed to load, the turn errored or produced nothing, `--verify` failed, `--resume` found no session, `init` refused to overwrite |
307
- | `2` | paused on a human-in-the-loop interrupt: an approval is needed but stdin is not a terminal, or you left the approval prompt with **Exit** or Ctrl-C. `--no-interactive` auto-approves instead |
307
+ | `2` | paused on a human-in-the-loop interrupt: an approval is needed but stdin is not a terminal, or you left the approval prompt with **Exit** or Ctrl-C. `--no-interactive` auto-approves instead, unless the pending action doesn't allow approve, which also exits `2` |
308
308
  | `64` | usage error: an unknown option or bad value, `--demo` with `-a`, `--continue` with `--resume`, `MESSAGE` with `-f`, an empty `MESSAGE` |
309
309
 
310
310
  ## Creating Your Own Agent
@@ -1833,23 +1833,24 @@ def handle_interrupt_input(
1833
1833
  except json.JSONDecodeError:
1834
1834
  return raw
1835
1835
 
1836
- options = [
1837
- "Approve all actions",
1838
- "Reject all actions",
1839
- "Provide custom decision (JSON)",
1840
- "Exit",
1841
- ]
1836
+ # "Approve all" / "Reject all" are offered only when every pending action allows
1837
+ # that verb. They used to be offered always, so on HumanInTheLoopMiddleware(
1838
+ # allowed_decisions=["approve", "edit"]) "Reject all" sent a decision the
1839
+ # middleware refuses and the turn errored (gh #197).
1840
+ entries = []
1841
+ if _all_actions_allow("approve", num_actions, interrupt):
1842
+ entries.append(("Approve all actions", "approve"))
1843
+ if _all_actions_allow("reject", num_actions, interrupt):
1844
+ entries.append(("Reject all actions", "reject"))
1845
+ entries += [("Provide custom decision (JSON)", "custom"), ("Exit", "exit")]
1846
+ options = [label for label, _ in entries]
1842
1847
 
1843
1848
  while True:
1844
- choice = select_option(options, "How would you like to proceed?")
1845
-
1846
- if choice == 0:
1847
- # Approve decision for each pending action
1848
- return {"decisions": [{"type": "approve"} for _ in range(num_actions)]}
1849
- elif choice == 1:
1850
- # Reject decision for each pending action
1851
- return {"decisions": [{"type": "reject"} for _ in range(num_actions)]}
1852
- elif choice == 2:
1849
+ action = entries[select_option(options, "How would you like to proceed?")][1]
1850
+
1851
+ if action in ("approve", "reject"):
1852
+ return {"decisions": [{"type": action} for _ in range(num_actions)]}
1853
+ elif action == "custom":
1853
1854
  decisions = _prompt_custom_decision(num_actions, interrupt)
1854
1855
  if decisions is _BACK_TO_MENU:
1855
1856
  continue # nothing sent; show the menu again
@@ -1932,6 +1933,16 @@ def _allowed_verbs(interrupt: Optional[Dict[str, Any]], index: int) -> List[str]
1932
1933
  return list(_FALLBACK_VERBS)
1933
1934
 
1934
1935
 
1936
+ def _all_actions_allow(verb: str, num_actions: int, interrupt: Optional[Dict[str, Any]]) -> bool:
1937
+ """Whether every pending action allows ``verb`` (gh #197)."""
1938
+ from langstage_core import normalize_decision
1939
+
1940
+ return all(
1941
+ normalize_decision(verb, _allowed_verbs(interrupt, i)) == verb
1942
+ for i in range(max(num_actions, 1))
1943
+ )
1944
+
1945
+
1935
1946
  def _decision_shapes(allowed: List[str], interrupt: Optional[Dict[str, Any]] = None) -> str:
1936
1947
  """One line showing the JSON shape of each allowed decision.
1937
1948
 
@@ -2658,6 +2669,19 @@ async def _stream_turn(
2658
2669
  f"(--no-interactive){RESET}"
2659
2670
  )
2660
2671
  resume = ""
2672
+ elif has_interrupt and not _all_actions_allow(
2673
+ "approve", num_pending_actions, interrupt_data
2674
+ ):
2675
+ # --no-interactive can only approve. An action that doesn't allow approve
2676
+ # would refuse the decision and error the turn, so stop paused instead and
2677
+ # say why (gh #197).
2678
+ print(
2679
+ "Error: approval required, but the pending action does not allow "
2680
+ f"approve (allowed: {', '.join(_allowed_verbs(interrupt_data, 0))}).\n"
2681
+ "Answer it in an interactive session.",
2682
+ file=sys.stderr,
2683
+ )
2684
+ sys.exit(EXIT_PAUSED)
2661
2685
  elif has_interrupt:
2662
2686
  # --no-interactive: auto-approve and resume so the agent runs to
2663
2687
  # completion (same behavior as the default path, gh #32).
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langstage-cli
3
- Version: 0.6.49
3
+ Version: 0.6.50
4
4
  Summary: The terminal stage for your LangGraph agent — Claude Code-style CLI for any CompiledGraph
5
5
  Author-email: Kedar Dabhadkar <kdabhadk@gmail.com>
6
6
  License-Expression: MIT
@@ -342,7 +342,7 @@ approval menu you answer by typing a number.
342
342
  |---|---|
343
343
  | `0` | success: the turn completed, `--verify` passed, `init` wrote its files |
344
344
  | `1` | failure: no agent configured, the agent failed to load, the turn errored or produced nothing, `--verify` failed, `--resume` found no session, `init` refused to overwrite |
345
- | `2` | paused on a human-in-the-loop interrupt: an approval is needed but stdin is not a terminal, or you left the approval prompt with **Exit** or Ctrl-C. `--no-interactive` auto-approves instead |
345
+ | `2` | paused on a human-in-the-loop interrupt: an approval is needed but stdin is not a terminal, or you left the approval prompt with **Exit** or Ctrl-C. `--no-interactive` auto-approves instead, unless the pending action doesn't allow approve, which also exits `2` |
346
346
  | `64` | usage error: an unknown option or bad value, `--demo` with `-a`, `--continue` with `--resume`, `MESSAGE` with `-f`, an empty `MESSAGE` |
347
347
 
348
348
  ## Creating Your Own Agent
@@ -40,6 +40,7 @@ tests/test_init.py
40
40
  tests/test_interrupt_non_tty.py
41
41
  tests/test_legacy_config_home.py
42
42
  tests/test_load_error.py
43
+ tests/test_menu_allowed_197.py
43
44
  tests/test_message_boundaries.py
44
45
  tests/test_no_color.py
45
46
  tests/test_no_interactive_approve.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "langstage-cli"
7
- version = "0.6.49"
7
+ version = "0.6.50"
8
8
  description = "The terminal stage for your LangGraph agent — Claude Code-style CLI for any CompiledGraph"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -0,0 +1,184 @@
1
+ """The approval menu offers only the decisions the pending interrupt allows (gh #197).
2
+
3
+ "Approve all actions" and "Reject all actions" were always offered, so on LangChain's
4
+ HumanInTheLoopMiddleware(allowed_decisions=["approve", "edit"]) "Reject all" sent a
5
+ decision the middleware refuses and the turn errored. ``--no-interactive`` likewise
6
+ sent an approve to an action that doesn't allow one. Each is now offered (or sent) only
7
+ when every pending action allows it.
8
+ """
9
+
10
+ import io
11
+ import textwrap
12
+ from contextlib import redirect_stdout
13
+
14
+ import pytest
15
+
16
+ from langstage_cli import cli
17
+
18
+
19
+ def _frame(*tools):
20
+ """An interrupt frame for (name, allowed_decisions) pairs, as core emits it."""
21
+ union = sorted({v for _, allowed in tools for v in allowed})
22
+ return {
23
+ "action_requests": [{"name": n, "args": {}} for n, _ in tools],
24
+ "review_configs": [{"action_name": n, "allowed_decisions": a} for n, a in tools],
25
+ "allowed_decisions": union,
26
+ }
27
+
28
+
29
+ @pytest.fixture
30
+ def tty(monkeypatch):
31
+ monkeypatch.setattr(cli, "_is_a_tty", lambda *a, **k: True)
32
+
33
+
34
+ def _pick(monkeypatch, label):
35
+ """Choose the menu entry ``label``, recording every menu shown."""
36
+ shown = []
37
+
38
+ def fake_select(options, prompt=""):
39
+ shown.append(list(options))
40
+ return options.index(label)
41
+
42
+ monkeypatch.setattr(cli, "select_option", fake_select)
43
+ return shown
44
+
45
+
46
+ @pytest.mark.parametrize(
47
+ "frame, expected",
48
+ [
49
+ (
50
+ _frame(("send_email", ["approve", "edit"])),
51
+ ["Approve all actions", "Provide custom decision (JSON)", "Exit"],
52
+ ),
53
+ (
54
+ _frame(("send_email", ["edit", "reject"])),
55
+ ["Reject all actions", "Provide custom decision (JSON)", "Exit"],
56
+ ),
57
+ (
58
+ _frame(("send_email", ["respond"])),
59
+ ["Provide custom decision (JSON)", "Exit"],
60
+ ),
61
+ # Per tool: one of two actions doesn't allow reject, so "Reject all" can't apply.
62
+ (
63
+ _frame(("a", ["approve", "reject"]), ("b", ["approve"])),
64
+ ["Approve all actions", "Provide custom decision (JSON)", "Exit"],
65
+ ),
66
+ # No allowed list at all (an older or plain interrupt): the full menu, as before.
67
+ (
68
+ None,
69
+ [
70
+ "Approve all actions",
71
+ "Reject all actions",
72
+ "Provide custom decision (JSON)",
73
+ "Exit",
74
+ ],
75
+ ),
76
+ ],
77
+ )
78
+ def test_menu_offers_only_allowed_bulk_decisions(frame, expected, tty, monkeypatch):
79
+ shown = _pick(monkeypatch, "Exit")
80
+ n = len(frame["action_requests"]) if frame else 1
81
+ with pytest.raises(SystemExit) as exc:
82
+ cli.handle_interrupt_input(n, interrupt=frame)
83
+ assert exc.value.code == 2
84
+ assert shown == [expected]
85
+
86
+
87
+ def test_each_entry_sends_its_own_decision(tty, monkeypatch):
88
+ frame = _frame(("a", ["edit", "reject"]), ("b", ["reject"]))
89
+ _pick(monkeypatch, "Reject all actions")
90
+ assert cli.handle_interrupt_input(2, interrupt=frame) == {
91
+ "decisions": [{"type": "reject"}, {"type": "reject"}]
92
+ }
93
+ _pick(monkeypatch, "Provide custom decision (JSON)")
94
+ monkeypatch.setattr("builtins.input", lambda *_a, **_k: '{"type": "reject"}')
95
+ with redirect_stdout(io.StringIO()):
96
+ assert cli.handle_interrupt_input(2, interrupt=frame) == {
97
+ "decisions": [{"type": "reject"}, {"type": "reject"}]
98
+ }
99
+
100
+
101
+ # ---- End to end on the issue's agent ------------------------------------------------
102
+
103
+ _AGENT = textwrap.dedent(
104
+ """
105
+ from langchain.agents import create_agent
106
+ from langchain.agents.middleware import HumanInTheLoopMiddleware
107
+ from langchain_core.language_models.chat_models import BaseChatModel
108
+ from langchain_core.messages import AIMessage
109
+ from langchain_core.outputs import ChatGeneration, ChatResult
110
+
111
+ class Model(BaseChatModel):
112
+ @property
113
+ def _llm_type(self):
114
+ return "fake-197"
115
+
116
+ def bind_tools(self, tools, **kw):
117
+ return self
118
+
119
+ def _generate(self, messages, stop=None, run_manager=None, **kw):
120
+ if messages[-1].type == "tool":
121
+ msg = AIMessage(content=f"done: {messages[-1].content}")
122
+ else:
123
+ msg = AIMessage(content="", tool_calls=[
124
+ {"name": "send_email", "args": {"to": "a@example.org"}, "id": "c1"}
125
+ ])
126
+ return ChatResult(generations=[ChatGeneration(message=msg)])
127
+
128
+ def send_email(to: str) -> str:
129
+ \"\"\"Send an email.\"\"\"
130
+ return f"sent to {to}"
131
+
132
+ graph = create_agent(
133
+ Model(),
134
+ tools=[send_email],
135
+ middleware=[HumanInTheLoopMiddleware(interrupt_on={
136
+ "send_email": {"allowed_decisions": ALLOWED},
137
+ })],
138
+ )
139
+ """
140
+ )
141
+
142
+
143
+ def _agent(allowed):
144
+ pytest.importorskip("ag_ui_langgraph")
145
+ from langgraph.checkpoint.memory import MemorySaver
146
+
147
+ from langstage_cli.agui_stream import build_session_agent
148
+
149
+ ns: dict = {"ALLOWED": allowed}
150
+ exec(_AGENT, ns)
151
+ return build_session_agent(ns["graph"].copy(update={"checkpointer": MemorySaver()}))
152
+
153
+
154
+ async def test_the_issue_agent_never_shows_reject_and_approve_runs_the_tool(tty, monkeypatch):
155
+ agent = _agent(["approve", "edit"])
156
+ shown = _pick(monkeypatch, "Approve all actions")
157
+ buf = io.StringIO()
158
+ with redirect_stdout(buf):
159
+ _elapsed, had_error = await cli.run_single_turn_agui(agent, "email them", "t-197", True)
160
+ out = buf.getvalue()
161
+ assert had_error is False, out
162
+ assert "done: sent to a@example.org" in out, out
163
+ assert all("Reject all actions" not in menu for menu in shown)
164
+
165
+
166
+ async def test_no_interactive_stops_paused_when_approve_is_not_allowed(monkeypatch, capsys):
167
+ agent = _agent(["edit", "reject"])
168
+ with pytest.raises(SystemExit) as exc:
169
+ await cli.run_single_turn_agui(agent, "email them", "t-197-ni", False)
170
+ assert exc.value.code == 2
171
+ err = capsys.readouterr().err
172
+ assert "does not allow approve (allowed: edit, reject)" in err
173
+ assert "ValueError" not in err
174
+ # Nothing was sent: the thread is still paused on the same approval.
175
+ assert await cli._pending_interrupt(agent, "t-197-ni")
176
+
177
+
178
+ async def test_no_interactive_still_auto_approves_when_allowed(monkeypatch):
179
+ agent = _agent(["approve", "edit"])
180
+ buf = io.StringIO()
181
+ with redirect_stdout(buf):
182
+ _elapsed, had_error = await cli.run_single_turn_agui(agent, "email them", "t-197-ok", False)
183
+ assert had_error is False
184
+ assert "done: sent to a@example.org" in buf.getvalue()
File without changes
File without changes