Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions gui_agents/s3/cli_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ def main():
default=False,
help="Enable local coding environment for code execution (WARNING: Executes arbitrary code locally)",
)
parser.add_argument(
"--task",
type=str,
help="The task instruction for Agent-S3 to perform.",
)

args = parser.parse_args()

Expand Down Expand Up @@ -367,19 +372,24 @@ def main():
max_trajectory_length=args.max_trajectory_length,
enable_reflection=args.enable_reflection,
)
task = args.task
if task is None or not isinstance(task, str) or len(task.strip())==0:
while True:
query = input("Query: ")

while True:
query = input("Query: ")
agent.reset()

agent.reset()
# Run the agent on your own device
run_agent(agent, query, scaled_width, scaled_height)

response = input("Would you like to provide another query? (y/n): ")
if response.lower() != "y":
break
else:
agent.reset()

# Run the agent on your own device
run_agent(agent, query, scaled_width, scaled_height)

response = input("Would you like to provide another query? (y/n): ")
if response.lower() != "y":
break

run_agent(agent, task, scaled_width, scaled_height)
Comment on lines +375 to +392
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Empty/whitespace --task values silently drop into interactive mode, which can surprise scripted usage

Right now:

task = args.task
if task is None or not isinstance(task, str) or len(task.strip())==0:
    # interactive mode
    ...
else:
    agent.reset()
    run_agent(agent, task, scaled_width, scaled_height)

This treats --task "" or --task " " as not providing a task and falls back to the interactive loop. In non‑interactive/scripted contexts (the main new use‑case), this can cause the process to hang waiting for input("Query: ") rather than failing fast.

It also slightly conflicts with the PR summary (“When the --task parameter is provided, the agent will be invoked once with the argument value used as its query.”), since providing a whitespace-only task doesn’t result in a single run.

Consider distinguishing “flag absent” from “flag present but empty” and failing fast for the latter, e.g.:

-    task = args.task
-    if task is None or not isinstance(task, str) or len(task.strip())==0:
+    task = args.task
+    if task is None:
         while True:
             query = input("Query: ")
@@
-    else:
-        agent.reset()
-        
-        # Run the agent on your own device
-        run_agent(agent, task, scaled_width, scaled_height)
+    else:
+        # Fail fast if --task was provided but empty/whitespace-only to avoid
+        # unexpectedly dropping into interactive mode in scripted usage.
+        if not task.strip():
+            print("--task must be a non-empty instruction string")
+            sys.exit(1)
+
+        agent.reset()
+
+        # Run the agent on your own device
+        run_agent(agent, task, scaled_width, scaled_height)

This keeps the legacy interactive behavior when --task is omitted, while making scripted behavior more predictable and CI‑friendly.


if __name__ == "__main__":
main()