# run_non_interactive

> **Function** in `deepagents_cli`

📖 [View in docs](https://reference.langchain.com/python/deepagents-cli/non_interactive/run_non_interactive)

Run a single task non-interactively and exit.

The agent is created with `interactive=False`, which tailors the system
prompt for autonomous headless execution (no clarification questions,
reasonable assumptions).

Shell access and auto-approval are controlled by `--shell-allow-list`:

- Not set → shell disabled, all other tools auto-approved.
- `recommended` or explicit list → shell enabled, commands gated by
    allow-list; non-shell tools approved unconditionally.
- `all` → shell enabled, any command allowed, all tools auto-approved.

Note: startup header rendering avoids synchronous LangSmith URL lookups.
A background thread resolves the thread URL concurrently and the result is
displayed after task completion if available.

## Signature

```python
run_non_interactive(
    message: str,
    assistant_id: str = 'agent',
    model_name: str | None = None,
    model_params: dict[str, Any] | None = None,
    sandbox_type: str = 'none',
    sandbox_id: str | None = None,
    sandbox_setup: str | None = None,
    *,
    initial_skill: str | None = None,
    profile_override: dict[str, Any] | None = None,
    quiet: bool = False,
    stream: bool = True,
    mcp_config_path: str | None = None,
    no_mcp: bool = False,
    trust_project_mcp: bool = False,
) -> int
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `message` | `str` | Yes | The task/message to execute. |
| `assistant_id` | `str` | No | Agent identifier for memory storage. (default: `'agent'`) |
| `model_name` | `str \| None` | No | Optional model name to use. (default: `None`) |
| `model_params` | `dict[str, Any] \| None` | No | Extra kwargs from `--model-params` to pass to the model.  These override config file values. (default: `None`) |
| `sandbox_type` | `str` | No | Type of sandbox (`'none'`, `'agentcore'`, `'daytona'`, `'langsmith'`, `'modal'`, `'runloop'`). (default: `'none'`) |
| `sandbox_id` | `str \| None` | No | Optional existing sandbox ID to reuse. (default: `None`) |
| `sandbox_setup` | `str \| None` | No | Optional path to setup script to run in the sandbox after creation. (default: `None`) |
| `initial_skill` | `str \| None` | No | Optional skill name whose `SKILL.md` instructions wrap the user message before sending it to the agent. (default: `None`) |
| `profile_override` | `dict[str, Any] \| None` | No | Extra profile fields from `--profile-override`.  Merged on top of config file profile overrides. (default: `None`) |
| `quiet` | `bool` | No | When `True`, all console output (headers, status messages, tool notifications, HITL decisions, errors) is redirected to stderr so that only the agent's response text appears on stdout. (default: `False`) |
| `stream` | `bool` | No | When `True` (default), text chunks are written to stdout as they arrive.  When `False`, the full response is buffered and written to stdout in one shot after the agent finishes. (default: `True`) |
| `mcp_config_path` | `str \| None` | No | Optional path to MCP servers JSON configuration file. Merged on top of auto-discovered configs (highest precedence). (default: `None`) |
| `no_mcp` | `bool` | No | Disable all MCP tool loading. (default: `False`) |
| `trust_project_mcp` | `bool` | No | When `True`, allow project-level stdio MCP servers. When `False` (default), project stdio servers are silently skipped. (default: `False`) |

## Returns

`int`

Exit code: 0 for success, 1 for error, 130 for keyboard interrupt.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/a827cddf72d72e4b17921b8eb445a3bfb0511cb4/libs/cli/deepagents_cli/non_interactive.py#L746)