opensre ask is OpenSRE’s headless CLI command. It runs one agent turn, prints
the response, and exits instead of opening the interactive shell. Each run is
saved as a resumable session unless you pass --ephemeral.
It uses the LLM provider from opensre onboard and any tools configured with
opensre integrations setup.
Follow-ups and required input
When the agent completes the request, a terminal run prints a session ID and a command you can use for a later follow-up:needs_input and prints numbered options. Resume the same session with the
option number, or a custom answer when the question allows one:
--ephemeral for scripts or one-off requests that should not write
resumable session history or print a session ID:
OPENSRE_PROMPT_LOG_DISABLED=1 to disable it,
including for ephemeral requests.
Live activity
When both output streams are attached to a terminal,ask starts with a
Thinking… spinner with elapsed time. It switches to the active diagnostic
tool (or a neutral tool count for a batch) when tools are invoked. The final
answer remains on standard output without echoing raw tool transcripts. Piped
and --json runs do not emit progress, so their output remains
machine-readable.
Pass - as the prompt to read all of standard input:
File context
Attach an alert, log excerpt, deployment note, or other regular UTF-8 text file with-i or --context-file while keeping the positional prompt as the instruction:
Tool approvals
Read-only tools run automatically. Tools that mutate state, contact an external service, explicitly require approval, or do not declare their side effects are denied by default. Authorize only the tools needed for this invocation by repeating--allowed-tool:
--yes (-y) option does
not authorize agent tools.
--dangerously-bypass-approvals authorizes every approval-gated tool for that
invocation. Use it only in a trusted environment where the prompt and connected
integrations are controlled:
--allowed-tool. Neither option bypasses
the operating-system permissions or sandboxing that applies to OpenSRE.
JSON output and exit codes
Put the global--json option before ask for machine-readable output:
status, response, session_id,
questions, denied_tools, and error. Each question includes its title,
label, options, whether it accepts multiple selections, and whether a custom
answer is allowed. The error value is either null or an object with
message and suggestion.
For required input, read session_id and questions from that object, then
pass the answer to another JSON invocation of the same session:
needs_input (exit code 4) with a question like:
status: "success", the same
session_id, and an empty questions array.
JSON mode emits no terminal-only continuation footer; use the returned ID.
--json is a global option, so it must appear before ask on both invocations.
Without --json, a required question also prints Session: ID on stderr when
output is redirected, so the choice can still be resumed.