# run_non_interactive

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/client/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 = DEFAULT_AGENT_NAME,
    model_name: str | None = None,
    model_params: dict[str, Any] | None = None,
    sandbox_type: str = 'none',
    sandbox_id: str | None = None,
    sandbox_snapshot_name: str | None = None,
    sandbox_setup: str | None = None,
    *,
    initial_skill: str | None = None,
    startup_cmd: 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,
    enable_interpreter: bool | None = None,
    interpreter_ptc: str | list[str] | None = None,
    interpreter_ptc_acknowledge_unsafe: bool = False,
    allow_fs_tools: list[FsToolName] | None = None,
    max_turns: int | None = None,
    rubric: str | None = None,
    rubric_model: str | None = None,
    rubric_max_iterations: int | None = None,
) -> int
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `message` | `str` | Yes | The task/message to execute. |
| `assistant_id` | `str` | No | Agent identifier for memory storage. (default: `DEFAULT_AGENT_NAME`) |
| `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_snapshot_name` | `str \| None` | No | Snapshot (langsmith) or blueprint (runloop) name. (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`) |
| `startup_cmd` | `str \| None` | No | Shell command to run at startup, before the agent runs.  Output follows the same console routing as other app messages: stdout by default, stderr when `-q` is set. Non-zero exits and timeouts warn but do not abort the task. (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`) |
| `enable_interpreter` | `bool \| None` | No | Enable the JS interpreter (`js_eval`) middleware on the main agent. `None` uses the sandbox-aware default. (default: `None`) |
| `interpreter_ptc` | `str \| list[str] \| None` | No | Override for `settings.interpreter_ptc` (PTC allowlist for `js_eval`). (default: `None`) |
| `interpreter_ptc_acknowledge_unsafe` | `bool` | No | Explicit acknowledgement for `interpreter_ptc="all"` outside of `auto_approve`. (default: `False`) |
| `allow_fs_tools` | `list[FsToolName] \| None` | No | Allowlist for `FilesystemMiddleware`'s `tools` param, from `--allow-fs-tools`.  `None` leaves the SDK default (all tools). (default: `None`) |
| `max_turns` | `int \| None` | No | Optional cap on total agentic turns. When `None`, the internal safety default applies. (default: `None`) |
| `rubric` | `str \| None` | No | Acceptance criteria for `RubricMiddleware`. When provided, the agent self-evaluates against it and loops until satisfied.  `None` disables rubric grading. (default: `None`) |
| `rubric_model` | `str \| None` | No | Grader model spec; `None` reuses the main model. (default: `None`) |
| `rubric_max_iterations` | `int \| None` | No | Grader iterations per rubric attempt; `None` uses the middleware default. (default: `None`) |

## Returns

`int`

Exit code: 0 for success, 1 for error, 124 when the `--max-turns`
budget was exceeded (matching GNU `timeout`), 130 for keyboard
interrupt.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/7794b61a6e76230e8c7a49bdce808b3728305914/libs/code/deepagents_code/client/non_interactive.py#L1342)