Skip to content

Commit 5898419

Browse files
Chathurangi ShyalikaChathurangi Shyalika
authored andcommitted
Adding OpenCode agent default mode and CLI workspace mode
1 parent cd22f63 commit 5898419

7 files changed

Lines changed: 483 additions & 47 deletions

File tree

INSTRUCTIONS.md

Lines changed: 80 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ Run from the **repo root**:
3939
uv sync
4040
```
4141

42-
`uv sync` creates a virtual environment at `.venv/`, installs all dependencies, and registers the CLI entry points (`plan-execute`, `*-mcp-server`). You can either prefix commands with `uv run` (no activation needed) or activate the venv once for your shell session:
42+
`uv sync` creates a virtual environment at `.venv/`, installs all dependencies,
43+
and registers the CLI entry points (`plan-execute`, `*-agent`, `*-mcp-server`).
44+
You can either prefix commands with `uv run` (no activation needed) or activate
45+
the venv once for your shell session:
4346

4447
```bash
4548
source .venv/bin/activate # macOS / Linux
@@ -92,25 +95,34 @@ See [MCP Servers](#mcp-servers) for available tools and [docs/mcp-servers.md](do
9295
| `WO_DBNAME` | `workorder` | Work order database name |
9396
| `VIBRATION_DBNAME` | `vibration` | Vibration sensor database name |
9497

95-
**WatsonX** — plan-execute runner (when `--model-id` starts with `watsonx/`)
98+
**WatsonX** — plan-execute runner and WatsonX-backed agent routes
9699

97100
| Variable | Default | Description |
98101
| -------------------- | ----------------------------------- | --------------------------- |
99102
| `WATSONX_APIKEY` | _(required)_ | IBM WatsonX API key |
100103
| `WATSONX_PROJECT_ID` | _(required)_ | IBM WatsonX project ID |
101104
| `WATSONX_URL` | `https://us-south.ml.cloud.ibm.com` | WatsonX endpoint (optional) |
102105

103-
**LiteLLM proxy** — used by every runner whenever `--model-id` carries the `litellm_proxy/` prefix (the default for claude-agent, openai-agent, deep-agent)
106+
**LiteLLM proxy** — used by every runner whenever `--model-id` carries the `litellm_proxy/` prefix
104107

105108
| Variable | Default | Description |
106109
| ------------------ | ------------ | -------------------------------------------------------------------- |
107110
| `LITELLM_API_KEY` | _(required)_ | LiteLLM proxy API key |
108111
| `LITELLM_BASE_URL` | _(required)_ | LiteLLM proxy base URL, e.g. `https://your-litellm-host.example.com` |
109112

110-
**TokenRouter** — OpenAI-compatible gateway, used whenever `--model-id` carries the `tokenrouter/` prefix (the default for direct-llm-agent)
113+
**TokenRouter** — OpenAI-compatible gateway, used whenever `--model-id` carries the `tokenrouter/` prefix
111114

112-
| `TOKENROUTER_API_KEY` | _(tokenrouter/* models)_ | TokenRouter API key |
113-
| `TOKENROUTER_BASE_URL` | _(tokenrouter/* models)_ | TokenRouter base URL, e.g. `https://api.tokenrouter.com/v1` |
115+
| Variable | Default | Description |
116+
| ---------------------- | ------------------------ | ------------------------------------------------------------------- |
117+
| `TOKENROUTER_API_KEY` | _(tokenrouter/* models)_ | TokenRouter API key |
118+
| `TOKENROUTER_BASE_URL` | _(tokenrouter/* models)_ | TokenRouter base URL, e.g. `https://api.tokenrouter.com/v1` |
119+
120+
**OpenCode direct providers**`opencode-agent` with direct provider routes
121+
122+
| Variable | Default | Description |
123+
| ------------------- | -------------------------- | ------------------------------------------------ |
124+
| `OPENAI_API_KEY` | _(openai/* models)_ | OpenAI API key, or configure through OpenCode |
125+
| `ANTHROPIC_API_KEY` | _(anthropic/* models)_ | Anthropic API key, or configure through OpenCode |
114126

115127
**Stirrup code track**`stirrup-agent` with `--code-backend docker`
116128

@@ -127,7 +139,7 @@ Six FastMCP servers cover IoT data, time-series ML, work orders, vibration diagn
127139

128140
| Server | Tools | Categories | Backing service |
129141
| ----------- | ----- | ------------------------ | -------------------------------------- |
130-
| `iot` | 7 | read | CouchDB (telemetry + asset registry) |
142+
| `iot` | 7 | read | CouchDB (telemetry + asset registry) |
131143
| `utilities` | 3 | read | none |
132144
| `fmsr` | 2 | read, LLM-use | LiteLLM + `failure_modes.yaml` |
133145
| `wo` | 14 | read, write | CouchDB |
@@ -154,16 +166,20 @@ query="What is the current date and time? Also list assets at site MAIN. Also ge
154166

155167
## Agents
156168

157-
Seven runners are available as CLIs registered by `uv sync`; six use MCP tools, while `direct-llm-agent` is a model-only baseline that makes a direct LiteLLM call without MCP tools, planning, retrieval, or code execution. Each is a CLI registered by `uv sync` that takes a single positional `question` argument and spawns the MCP servers as stdio subprocesses on demand.
169+
Seven runners are available as CLIs registered by `uv sync`; six use MCP tools,
170+
while `direct-llm-agent` is a model-only baseline that makes a direct LiteLLM
171+
call without MCP tools, planning, retrieval, or code execution. Each takes a
172+
single positional `question` argument and spawns the MCP servers as stdio
173+
subprocesses on demand.
158174

159175
| Runner | Source | Loop | Default model |
160176
| -------------- | ---------------------------- | ------------------------------------------------------------- | ----------------------------------------------------------- |
161177
| `plan-execute` | `src/agent/plan_execute/` | Custom plan → execute → summarise (no SDK) | `watsonx/meta-llama/llama-4-maverick-17b-128e-instruct-fp8` |
162178
| `claude-agent` | `src/agent/claude_agent/` | [`claude-agent-sdk`](https://github.com/anthropics/claude-agent-sdk-python) agentic loop | `litellm_proxy/aws/claude-opus-4-6` |
163-
| `openai-agent` | `src/agent/openai_agent/` | [`openai-agents`](https://github.com/openai/openai-agents-python) SDK Runner | `litellm_proxy/azure/gpt-5.4` |
179+
| `openai-agent` | `src/agent/openai_agent/` | [`openai-agents`](https://github.com/openai/openai-agents-python) SDK Runner | `litellm_proxy/azure/gpt-5.4` |
164180
| `deep-agent` | `src/agent/deep_agent/` | [LangChain deep-agents](https://docs.langchain.com/oss/python/deepagents/overview) (LangGraph), MCP bridged via `langchain-mcp-adapters` | `litellm_proxy/aws/claude-opus-4-6` |
165181
| `stirrup-agent` | `src/agent/stirrup_agent/` | [Stirrup](https://github.com/ArtificialAnalysis/Stirrup) agent loop (in-process), MCP via its `MCPToolProvider`; **code-capable** (writes/runs Python) | `watsonx/meta-llama/llama-4-maverick-17b-128e-instruct-fp8` |
166-
| `opencode-agent` | `src/agent/opencode_agent/` | [OpenCode](https://opencode.ai/docs/) CLI agent loop, MCP via generated OpenCode config; web/bash/edit denied by default | `opencode/gpt-5.1-codex` |
182+
| `opencode-agent` | `src/agent/opencode_agent/` | [OpenCode](https://opencode.ai/docs/) CLI agent loop, MCP via generated OpenCode config; MCP-only by default with optional CLI workspace mode | `opencode/gpt-5.1-codex` |
167183
| `direct-llm-agent` | `src/agent/direct_llm_agent/` | Single direct LLM call, no MCP tools, planning, retrieval, or code execution | `litellm_proxy/Azure/gpt-5-mini-2025-08-07` |
168184

169185
- [Agents](#agents) — Stirrup specifics in [docs/stirrup-agent.md](docs/stirrup-agent.md); OpenCode specifics in [docs/opencode-agent.md](docs/opencode-agent.md)
@@ -203,6 +219,7 @@ uv run direct-llm-agent "$query"
203219
| `--max-tokens N` | stirrup-agent | Max output tokens per call; keep under provider limit (default 16384) |
204220
| `--max-steps N` | opencode-agent | Max OpenCode agentic iterations (default: 30) |
205221
| `--attach URL` | opencode-agent | Attach to a running `opencode serve` instance |
222+
| `--allow-files` / `--workspace-dir PATH` | opencode-agent | Enable local file inspection in a dedicated workspace |
206223
| `--allow-bash` / `--allow-edit` / `--allow-web` | opencode-agent | Opt into shell, file edits, or web access; all denied by default |
207224

208225
### Examples
@@ -229,14 +246,52 @@ uv run stirrup-agent --no-code --show-trajectory \
229246
STIRRUP_CODE_IMAGE=assetops-code \
230247
uv run stirrup-agent --code-backend docker "$query"
231248

232-
# OpenCode CLI-backed agent, using TokenRouter
249+
# OpenCode MCP-only CLI-backed agent, using TokenRouter
233250
uv run opencode-agent --model-id tokenrouter/MiniMax-M3 --show-trajectory "$query"
234251

252+
# OpenCode CLI workspace mode, allowing file inspection and bash in a run workspace
253+
uv run opencode-agent \
254+
--model-id tokenrouter/MiniMax-M3 \
255+
--workspace-dir /tmp/assetopsbench-opencode/smoke \
256+
--allow-files \
257+
--allow-bash \
258+
--show-trajectory \
259+
"$query"
260+
235261
# Direct model-only baseline, no MCP tools
236262
uv run direct-llm-agent --model-id litellm_proxy/Azure/gpt-5-mini-2025-08-07 \
237263
'Return only JSON: {"test": 1}'
238264
```
239265

266+
### OpenCode scenario-suite workspace mode
267+
268+
The scenario-suite runner can create one workspace per OpenCode run and pass
269+
optional CLI capabilities through to `opencode-agent`:
270+
271+
```bash
272+
uv run python -m benchmark.scenario_suite_runner \
273+
--scenario-ids benchmarks/scenario_suite/scenarios.txt \
274+
--scenario-root /path/to/scenarios_data \
275+
--agent_name opencode_agent \
276+
--model-id tokenrouter/MiniMax-M3 \
277+
--opencode-workspace-root traces/opencode_workspaces \
278+
--opencode-allow-files \
279+
--opencode-allow-bash
280+
```
281+
282+
For scenario `401`, this creates a workspace like:
283+
284+
```text
285+
traces/opencode_workspaces/opencode_agent_401
286+
```
287+
288+
`--opencode-allow-files`, `--opencode-allow-bash`, and
289+
`--opencode-allow-edit` are opt-in. If any of them are enabled,
290+
`--opencode-workspace-root` is required.
291+
292+
> `--opencode-allow-bash` is not a hard OS-level sandbox. For strict filesystem
293+
> isolation, run the benchmark inside Docker or another sandbox.
294+
240295
---
241296

242297
## Observability
@@ -325,16 +380,17 @@ uv run pytest src/ -k "integration" # only files / tests with "in
325380
## Architecture
326381

327382
```
328-
┌──────────────────────────────────────────────────────────────┐
329-
│ agent/ │
330-
│ │
331-
│ PlanExecuteRunner ClaudeAgentRunner StirrupAgentRunner │
332-
│ OpenAIAgentRunner DeepAgentRunner │
333-
│ │
334-
└──────────────────────────┬───────────────────────────────────┘
335-
│ MCP protocol (stdio)
336-
┌─────────────────┼───────────┬──────────┬──────┬───────────┐
337-
▼ ▼ ▼ ▼ ▼ ▼
338-
iot utilities fmsr tsfm wo vibration
339-
(tools) (tools) (tools) (tools) (tools) (tools)
340-
```
383+
┌────────────────────────────────────────────────────────────────────────┐
384+
│ agent/ │
385+
│ │
386+
│ PlanExecuteRunner ClaudeAgentRunner StirrupAgentRunner │
387+
│ OpenAIAgentRunner DeepAgentRunner OpenCodeAgentRunner │
388+
│ DirectLLMAgentRunner │
389+
│ │
390+
└──────────────────────────────┬─────────────────────────────────────────┘
391+
│ MCP protocol (stdio)
392+
┌─────────────────────┼───────────┬──────────┬──────┬───────────┐
393+
▼ ▼ ▼ ▼ ▼ ▼
394+
iot utilities fmsr tsfm wo vibration
395+
(tools) (tools) (tools) (tools) (tools) (tools)
396+
```

0 commit comments

Comments
 (0)