Personal AI, On Personal Devices
Python
feat(cli): wire confirm_callback for `jarvis agents ask` (with --yes/--no-yes)
Gilles Ceyssat333cb9a37094
diff --git a/src/openjarvis/cli/agent_cmd.py b/src/openjarvis/cli/agent_cmd.pyindex db24144c..31724ef5 100644--- a/src/openjarvis/cli/agent_cmd.py+++ b/src/openjarvis/cli/agent_cmd.py@@ -702,16 +702,34 @@ def errors():@agent.command("ask")@click.argument("agent_id")@click.argument("message")-def ask(agent_id, message):+ "--yes/--no-yes",+ "auto_approve",+ default=True,+ help="Auto-approve tool execution that would otherwise need confirmation. "+ "Default: on (suits non-interactive CLI use). Pass --no-yes to require a "+ "TTY prompt for tools whose ToolSpec sets requires_confirmation=True.",+)+def ask(agent_id, message, auto_approve):"""Ask an agent a question (immediate response)."""manager = _get_manager()agent_id = _resolve_agent_id(manager, agent_id)manager.send_message(agent_id, message, mode="immediate")click.echo("Asking agent...")- _, executor, _ = _get_scheduler_and_executor()+ _, executor, system = _get_scheduler_and_executor()if executor is None:click.echo("Executor not available", err=True)raise SystemExit(1)+ # Wire a confirmation callback so the agent's own ToolExecutor can actually+ # run tools whose ToolSpec sets requires_confirmation=True (e.g. shell_exec,+ # git_*). `executor` is the AgentExecutor; the callback is read in+ # _invoke_agent and propagated to the constructed agent via agent_kwargs.+ if auto_approve:+ executor._confirm_callback = lambda _prompt: True+ else:+ executor._confirm_callback = (+ lambda prompt: click.confirm(f"\n{prompt}", default=False)+ )executor.execute_tick(agent_id)msgs = manager.list_messages(agent_id)responses = [m for m in msgs if m["direction"] == "agent_to_user"]