Skip to content

Commit c9ae95d

Browse files
authored
Merge pull request #67 from VibePod/issue-64
Document and test forwarding of agent-specific startup args
2 parents d649689 + 12fc1b6 commit c9ae95d

6 files changed

Lines changed: 116 additions & 1 deletion

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ vp run codex
4545
vp run vibe # alias of devstral
4646
```
4747

48+
Extra arguments after the agent are forwarded to the agent process. Use `--`
49+
before agent flags so VibePod does not parse them as its own options:
50+
51+
```bash
52+
vp run <agent> -- <agent-args>
53+
```
54+
4855
## IKWID Mode (`--ikwid`)
4956

5057
Use `--ikwid` to append each agent's auto-approval / permission-skip flag when supported.

docs/agents/index.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,23 @@ agents:
153153
MY_VAR: value
154154
```
155155

156+
## Passing arguments to the agent
157+
158+
Any extra arguments after the agent name are appended to the agent command inside the container:
159+
160+
```bash
161+
vp run <agent> <agent-args>
162+
```
163+
164+
Use `--` before agent flags so VibePod does not parse them as its own options:
165+
166+
```bash
167+
vp run <agent> -- <agent-flag> <value>
168+
```
169+
170+
For concrete syntax, check the agent's own CLI help. For example, Claude and
171+
Codex both accept model flags, but their exact flag names and values differ.
172+
156173
## Init scripts before startup
157174

158175
Use `agents.<agent>.init` to run shell commands in the container before the agent launches. This is useful for installing extra tools in a custom image workflow.

docs/quickstart.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,20 @@ Use `-w` / `--workspace` to target any directory:
5353
vp run claude -w ~/other-project
5454
```
5555

56+
## Pass arguments to the agent
57+
58+
Arguments after the agent name are forwarded to the agent command inside the container:
59+
60+
```bash
61+
vp run <agent> <agent-args>
62+
```
63+
64+
When forwarding flags to the agent, use `--` to stop VibePod option parsing:
65+
66+
```bash
67+
vp run <agent> -- <agent-flag> <value>
68+
```
69+
5670
## Bootstrap a project config
5771

5872
Create a project-level config file that you can extend later:

src/vibepod/commands/run.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ def run(
281281
"""Start an agent container.
282282
283283
Any trailing arguments after the agent name are forwarded to the agent's
284-
command inside the container, e.g. `vp run claude setup-token`.
284+
command inside the container. Use `--` before agent flags when they could
285+
be parsed as VibePod flags.
285286
"""
286287
click_ctx = click.get_current_context(silent=True)
287288
passthrough_args: list[str] = (

tests/test_cli.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,21 @@ def _fake_run(agent=None, **kwargs) -> None: # noqa: ANN001, ANN003, ARG001
5656
assert result.exit_code == 0
5757
assert called["agent"] == "claude"
5858
assert called["passthrough"] == ["setup-token"]
59+
60+
61+
def test_alias_forwards_extra_option_args_after_delimiter(monkeypatch) -> None:
62+
called: dict[str, object] = {"agent": None, "passthrough": None}
63+
64+
def _fake_run(agent=None, **kwargs) -> None: # noqa: ANN001, ANN003, ARG001
65+
import click
66+
67+
ctx = click.get_current_context(silent=True)
68+
called["agent"] = agent
69+
called["passthrough"] = list(ctx.args) if ctx and ctx.args else []
70+
71+
monkeypatch.setattr(run_cmd, "run", _fake_run)
72+
73+
result = runner.invoke(app, ["claude", "--", "--model", "sonnet", "hello"])
74+
assert result.exit_code == 0
75+
assert called["agent"] == "claude"
76+
assert called["passthrough"] == ["--model", "sonnet", "hello"]

tests/test_run.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
import pytest
99
import typer
10+
from typer.testing import CliRunner
1011

12+
from vibepod.cli import app
1113
from vibepod.commands import run as run_cmd
1214
from vibepod.constants import EXIT_DOCKER_NOT_RUNNING
1315
from vibepod.core.docker import DockerClientError, DockerManager
@@ -470,6 +472,62 @@ def _make_config(
470472
}
471473

472474

475+
def test_cli_run_forwards_extra_args_to_agent_command(monkeypatch, tmp_path: Path) -> None:
476+
"""Extra args after -- are appended to the agent command as-is."""
477+
captured: dict = {}
478+
479+
class _CapturingDockerManager:
480+
def ensure_network(self, name: str) -> None:
481+
pass
482+
483+
def networks_with_running_containers(self) -> list[str]:
484+
return []
485+
486+
def pull_image(self, image: str) -> None:
487+
pass
488+
489+
def ensure_proxy(self, **kwargs) -> None: # type: ignore[no-untyped-def]
490+
pass
491+
492+
def run_agent(self, **kwargs) -> object: # type: ignore[no-untyped-def]
493+
captured.update(kwargs)
494+
container = type(
495+
"_Container",
496+
(),
497+
{
498+
"name": "vibepod-claude-test",
499+
"id": "abc123",
500+
"status": "running",
501+
"attrs": {"NetworkSettings": {"Networks": {}}},
502+
"reload": lambda self: None,
503+
"labels": {},
504+
"logs": lambda self, **kw: b"",
505+
},
506+
)()
507+
return container
508+
509+
monkeypatch.setattr(run_cmd, "get_config", lambda: _make_config())
510+
monkeypatch.setattr(run_cmd, "DockerManager", _CapturingDockerManager)
511+
512+
result = CliRunner().invoke(
513+
app,
514+
[
515+
"run",
516+
"-d",
517+
"-w",
518+
str(tmp_path),
519+
"claude",
520+
"--",
521+
"--model",
522+
"sonnet",
523+
"hello world",
524+
],
525+
)
526+
527+
assert result.exit_code == 0, result.output
528+
assert captured["command"] == ["claude", "--model", "sonnet", "hello world"]
529+
530+
473531
def test_auto_pull_global_triggers_pull(monkeypatch, tmp_path: Path) -> None:
474532
"""Global auto_pull=true causes image pull on run."""
475533
stub = _StubDockerManager()

0 commit comments

Comments
 (0)