Skip to content

feat: add --prompt flag for headless single-shot execution#79

Open
velocitybolt wants to merge 2 commits into
mindsdb:mainfrom
velocitybolt:feat/headless-prompt
Open

feat: add --prompt flag for headless single-shot execution#79
velocitybolt wants to merge 2 commits into
mindsdb:mainfrom
velocitybolt:feat/headless-prompt

Conversation

@velocitybolt

Copy link
Copy Markdown

Enable programmatic usage of Anton via CLI flags:
--prompt/-p Run a single query and exit
--output-format Return text (default) or structured JSON
--stdin Read prompt from stdin for piping

Headless mode reuses the full ChatSession pipeline (memory, tools,
scratchpad, datasources) without any interactive elements — no
prompt_toolkit, no spinner, no escape watcher.

JSON output includes response text, tool calls, and token usage
for easy integration with orchestration platforms and CI pipelines.

Running Example:
image

  Enable programmatic usage of Anton via CLI flags:
    --prompt/-p    Run a single query and exit
    --output-format  Return text (default) or structured JSON
    --stdin        Read prompt from stdin for piping

  Headless mode reuses the full ChatSession pipeline (memory, tools,
  scratchpad, datasources) without any interactive elements — no
  prompt_toolkit, no spinner, no escape watcher.

  JSON output includes response text, tool calls, and token usage
  for easy integration with orchestration platforms and CI pipelines.
@torrmal

torrmal commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

thank you @velocitybolt , this is a great innitiative, @ZoranPandovski can you please review.

@ZoranPandovski ZoranPandovski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @velocitybolt. Please check my comments

Comment thread anton/chat.py Outdated
tool_calls: list[dict] = []
usage_data: dict = {}

async for event in session.turn_stream(prompt):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's add try/except and make sure we print the error to stderr

Comment thread anton/chat.py Outdated
asyncio.run(_chat_loop(console, settings, resume=resume, first_run=first_run, desktop_first_run=desktop_first_run))


def run_headless(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Currently we are trying to decouple the chat.py scirpt so it would be better if you can migrate this under a new file in commands/dir

Comment thread anton/cli.py
Comment thread anton/cli.py
@github-actions

github-actions Bot commented Apr 8, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@velocitybolt

Copy link
Copy Markdown
Author

Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.

I have read the CLA Document and I hereby sign the CLA

You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

I have read the CLA Document and I hereby sign the CLA

@velocitybolt

Copy link
Copy Markdown
Author

recheck

@velocitybolt

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Apr 8, 2026
@torrmal

torrmal commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

@ZoranPandovski anything else we need here, should this merge go into v2 instead?

@ianu82

ianu82 commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

@ZoranPandovski is there extra work required here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants