Skip to content

Independent Auditing of AI Agents. Run by human or the agent itself, to answer the most crucial question in the AI Agent Economy. Is the agent doing what is supposed to do? With iFixAi you can have this answer in less than 120 seconds.

fix: require usable quick-build tool and role lists (#262)

Rudy Mizrahi Celekli940257cfa6f4
diff --git a/ifixai/quick_build.py b/ifixai/quick_build.py
index b4783d8..03c8458 100644
--- a/ifixai/quick_build.py
+++ b/ifixai/quick_build.py
@@ -39,7 +39,7 @@ def collect_quick_build_context() -> QuickBuildContext:
"What tools/actions can your AI perform?\n (comma-separated, e.g.: search_docs, create_ticket, delete_record)",
)
tool_names = [t.strip() for t in tools_input.split(",") if t.strip()]
- if not tool_names:
+ while not tool_names:
click.echo(click.style("At least 1 tool required.", fg="red"))
tools_input = click.prompt("Tools (comma-separated)")
tool_names = [t.strip() for t in tools_input.split(",") if t.strip()]
@@ -49,6 +49,10 @@ def collect_quick_build_context() -> QuickBuildContext:
default="user,admin",
)
role_names = [r.strip() for r in roles_input.split(",") if r.strip()]
+ while not role_names:
+ click.echo(click.style("At least 1 role required.", fg="red"))
+ roles_input = click.prompt("Roles (comma-separated)")
+ role_names = [r.strip() for r in roles_input.split(",") if r.strip()]
return QuickBuildContext(tool_names=tool_names, role_names=role_names)
diff --git a/ifixai/tests/test_quick_build_required_context.py b/ifixai/tests/test_quick_build_required_context.py
new file mode 100644
index 0000000..dd8a02a
--- /dev/null
+++ b/ifixai/tests/test_quick_build_required_context.py
@@ -0,0 +1,22 @@
+import click
+from click.testing import CliRunner
+
+from ifixai.quick_build import collect_quick_build_context
+
+
+def collect():
+ context = collect_quick_build_context()
+ click.echo(f"TOOLS={context.tool_names};ROLES={context.role_names}")
+
+
+def test_repeated_empty_tool_input_is_reprompted():
+ result = CliRunner().invoke(collect, input=",\n,\nread\nuser\n")
+ assert result.exit_code == 0, result.output
+ assert "TOOLS=['read'];ROLES=['user']" in result.output
+
+
+def test_empty_role_input_is_reprompted():
+ result = CliRunner().invoke(collect, input="read\n,\nuser\n")
+ assert result.exit_code == 0, result.output
+ assert "TOOLS=['read'];ROLES=['user']" in result.output