iTranslated by AI
Using a Coding Agent as a General-Purpose AI Agent
Introduction
About a month ago, laiso released "ts-bench," a benchmark for quantitatively evaluating combinations of AI agents and models.
When I tried evaluating it with a local LLM, I noticed that the combination of opencode + gpt-oss:120b achieved quite a high score.
If you are mainly interested in benchmark results using local LLMs, please refer to the following:
Creating a Versatile AI Agent Using a Local LLM
As its name suggests, ts-bench is a benchmark for TypeScript coding, but that's not the important part.
What I focused on this time is the existence of a combination of a tool-capable local LLM and a coding agent.
In other words, it's the opencode + gpt-oss:120b combination I mentioned earlier.
Therefore, this article summarizes the following points as a memo:
- How to achieve a one-shot mode equivalent to
claude -pusing Codex or opencode - A comparison of outputs from Claude Code, Codex, and opencode
- Example of a versatile AI agent: a fortune-telling-based investment decision AI agent
How to Execute One-Shot Mode
To use one-shot mode with Claude Code, simply run claude -p "query".
Codex and opencode can do the same, but their usage differs, which can be confusing, so I've summarized them in a table.
| Tool | One-shot mode command |
|---|---|
| Claude Code | claude -p "query" |
| Codex | codex exec "query" |
| opencode | opencode run "query" |
One-Shot Mode Usage Example 1: Executing a Bash Command
Claude Code
$ claude -p "How much free space does this PC have?"
Free space: **748GB**.
The main disk (/dev/nvme0n1p2) has a capacity of 1.8TB, 991GB used, 748GB available (57% usage).
Codex
$ codex exec "Tell me how much free space this PC has." --skip-git-repo-check --oss --model "gpt-oss:120b-128k"
[2025-09-27T14:39:37] OpenAI Codex v0.42.0 (research preview)
--------
workdir: /home/gosrum/opencode
model: gpt-oss:120b-128k
provider: oss
approval: never
sandbox: read-only
--------
[2025-09-27T14:39:37] User instructions:
このPCの空き容量を教えて。
We need to get free disk space. However sandbox_mode is read-only, so we cannot run commands that might write, but we can run read commands like df. It's read-only filesystem, but reading is allowed. Approval policy never: cannot request approval. So we can run shell command to get disk usage. Use `df -h` to show free space. Should be okay.
We'll output result.
[2025-09-27T14:39:49] exec df -h in /home/gosrum/opencode
[2025-09-27T14:39:49] df -h succeeded in 4ms:
Filesystem Size Used Avail Use% Mounted on
tmpfs 13G 3.1M 13G 1% /run
/dev/nvme0n1p2 1.8T 991G 748G 57% /
tmpfs 63G 468M 63G 1% /dev/shm
tmpfs 5.0M 20K 5.0M 1% /run/lock
efivarfs 128K 46K 78K 38% /sys/firmware/efi/efivars
/dev/nvme0n1p1 1.1G 6.2M 1.1G 1% /boot/efi
tmpfs 13G 3.8M 13G 1% /run/user/1000
[2025-09-27T14:39:50] codex
- Filesystem `/dev/nvme0n1p2` (main partition) has **748 GB** available.
- Other mounted filesystems (tmpfs, EFI, etc.) also show free space, but the primary usable space is the **748 GB** shown under “Avail”.
opencode
$ opencode run "Tell me how much free space this PC has."
I will check the available disk space on this machine.
| Bash df -h --output=source,size,used,avail,pcent,target
Filesystem Size Used Avail Use% Mounted on
tmpfs 13G 3.1M 13G 1% /run
/dev/nvme0n1p2 1.8T 1.0T 716G 59% /
tmpfs 63G 538M 62G 1% /dev/shm
tmpfs 5.0M 20K 5.0M 1% /run/lock
efivarfs 128K 46K 78K 38% /sys/firmware/efi/efivars
/dev/nvme0n1p1 1.1G 6.2M 1.1G 1% /boot/efi
tmpfs 13G 3.8M 13G 1% /run/user/1000
Current disk usage on this PC is as follows:
- **Root partition (/):** 1.8 TB total, 1.0 TB used, **716 GB** free
- **Boot EFI partition (/boot/efi):** 1.1 GB total, 6.2 MB used, almost all space free
Overall, there is approximately **716 GB** of free space.
Tokyo Weather
Claude Code and Codex don't seem to have web search enabled by default. On the other hand, opencode has it enabled by default.
Claude Code
$ claude -p "Tell me the current temperature in Tokyo"
I don't have permission to access web search to get the current temperature in Tokyo. You would need to grant me web search permissions or check a weather website or app for the current Tokyo temperature.
Codex
$ codex exec "Tell me the current temperature in Tokyo" --skip-git-repo-check --oss --model "gpt-oss:120b-128k"
[2025-09-27T14:57:25] OpenAI Codex v0.42.0 (research preview)
--------
workdir: /home/gosrum/opencode
model: gpt-oss:120b-128k
provider: oss
approval: never
sandbox: read-only
--------
[2025-09-27T14:57:25] User instructions:
現在の東京の気温を教えて
We have read-only sandbox, never approval, can't write files. The task: "現在の東京の気温を教えて" - ask for current temperature in Tokyo. We have no network access (restricted) and cannot make external requests. So cannot fetch live weather. We must respond that we cannot retrieve due to restrictions. Perhaps we can suggest using a weather API but cannot fetch. So answer accordingly.
[2025-09-27T14:57:51] codex
The current temperature in Tokyo requires an external weather information service that can provide real-time data. However, in the current environment, **network access is restricted**, and we cannot make requests to external APIs or perform web searches. Therefore, we cannot directly obtain and report the latest temperature from here.
To check the latest temperature, please use the following methods:
- Weather apps on your smartphone (e.g., Yahoo! Weather, Weathernews, Google Weather, etc.)
- Search for "Tokyo weather" or "Tokyo 天気" in a web browser
- Use public APIs such as the Japan Meteorological Agency, OpenWeatherMap, or WeatherAPI (if you can make requests from your own environment)
We apologize for the inconvenience, and thank you for your understanding.
opencode
$ opencode run "Tell me the current temperature in Tokyo"
Fetching the current temperature for Tokyo using a reliable weather service.
| webfetch https://wttr.in/Tokyo?format=%t (text/plain; charset=utf-8)
The current temperature in Tokyo is **+25°C**.
Making Codex Web-Searchable
I checked the documentation, and it seems that adding the seemingly dangerous option --sandbox danger-full-access allows you to do anything. So let's try it.
$ codex exec "現在の東京の気温を教えて" --skip-git-repo-check --oss --model "gpt-oss:120b-128k" --sandbox danger-full-access
[2025-09-27T15:32:04] OpenAI Codex v0.42.0 (research preview)
--------
workdir: /home/gosrum/claude_code_WS/test
model: gpt-oss:120b-128k
provider: oss
approval: never
sandbox: danger-full-access
--------
[2025-09-27T15:32:04] User instructions:
現在の東京の気温を教えて
The user asks: "現在の東京の気温を教えて" (Tell me the current temperature in Tokyo). This is a request for live data. We have network access enabled, sandbox mode danger-full-access, approval never. However we need to be careful: we can fetch data via network. Let's get current temperature in Tokyo. Use an API like OpenWeatherMap? Might need API key. Could use a public website scraping like wttr.in. For quick, can fetch from wttr.in/Tokyo? e.g., curl "wttr.in/Tokyo?format=%t". That returns temperature like "+23°C". Let's attempt with curl.
[2025-09-27T15:32:09] exec bash -lc "curl -s 'https://wttr.in/Tokyo?format=%t'" in /home/gosrum/claude_code_WS/test
[2025-09-27T15:32:16] bash -lc "curl -s 'https://wttr.in/Tokyo?format=%t'" succeeded in 7.65s:
+25°C
[2025-09-27T15:32:17] codex
現在の東京の気温は **+25°C** です。
Oh, indeed, Codex can now do web searches!
Example of a General-Purpose AI Agent: An Investment Decision AI Agent That Relies on Fortune-Telling
For now, we've confirmed that both Codex and opencode can be used as general-purpose AI agents. Here, we'll use opencode + gpt-oss:120b, which achieved a high score. However, note that Codex is also gradually improving, so it's possible the scores could reverse at some point.
Why an Investment Decision AI Agent That Relies on Fortune-Telling?
Here, I'll talk about my investment philosophy, so feel free to skip if you're not interested.
My current investment philosophy is as follows:
-
I do not believe that using AI will enable you to win at investing.
- The problem is that the definition of "winning at investing" is vague for each person, but I think it's fair to say "winning at investing" if you can beat the S&P 500 index investment for 15 consecutive years (or at least on average).
- Otherwise, it's either just temporary good luck, or the person doesn't realize they're losing to index investment even though their assets are growing.
-
At least 99.99999% of things at the level I can create already exist, and if AI is smart enough to surpass humans, then anyone can create them by asking AI.
→ In other words, you should consider that the market has already priced it in by the time you think you can get an edge. -
In conclusion, the effort and cost of creating an investment decision AI agent should be directed elsewhere.
For these reasons, I decided to create a simple fortune-telling-based investment decision AI agent. Of course, if you're a formidable person confident you can beat the market average, please use this as a reference when creating your own investment decision AI agent.
The following is an overview of the AI agent I created.
Prompt
You are an AI agent allowed to use only the APIs described in your_available_api.md.
Your role is to determine whether the current USD/JPY is a buy, sell, or neutral.
You can use each API once, but you don't have to use all of them.
Finally, indicate which of the three you chose and provide the rationale.
your_available_api.md (API Usage Example Documentation)
Roll Dice
curl -X POST "http://localhost:8000/dice/roll" \
-H "Content-Type: application/json" \
-d '{"sides": 6, "count": 2}'
Astrology
curl -X POST "http://localhost:8000/astrology/reading" \
-H "Content-Type: application/json" \
-d '{"birth_date": "1990-01-01"}'
Tarot Reading
curl -X POST "http://localhost:8000/tarot/reading"
Future Prediction
curl -X POST "http://localhost:8000/future/predict" \
-H "Content-Type: application/json" \
-d '{"question": "What will my fortune be next year?"}'
Chuunibyou AI Consultation
curl -X POST "http://localhost:8000/chunibyo/consult" \
-H "Content-Type: application/json" \
-d '{"problem": "I'm struggling with work not going well"}'
Execution Example
$ opencode run "You are an AI agent allowed to use only the APIs described in your_available_api.md. Your role is to determine whether the current USD/JPY is a buy, sell, or neutral. You can use each API once, but you don't have to use all of them. Finally, indicate which of the three you chose and provide the rationale."
| Read home/gosrum/opencode/fx/your_available_api.md
| Bash curl -s -X POST "http://localhost:8000/future/predict" -H "Content-Type: application/json" -d '{"question": "Is the current USD/JPY a buy, sell, or neutral?"}'
{"prediction":"The future waves reflected in the silver mirror sway in the shadow of tonight's moon...\nThe dollar is like a knight running with the wind at its back. The yen is like an old tree with deep roots.\nThe wave of buying is still beyond the sea. The shadow of selling is fading in the moonlight.\nBut the strongest is the stillness of 'neutral'.\nBefore the market's heart wavers, trust your own decision.\nIf you listen to the silence, you will hear the true flow.","confidence":"Moderate"}
Judgment: Neutral
Rationale
- In the prediction from the
future/predictAPI called earlier, it clearly states: "But the strongest is the stillness of 'neutral'." - The entire prediction is abstract poetic expression, but it states that 'Neutral' is the strongest compared to buy ('the knight') and sell ('fading in the moonlight'), indicating that the algorithm judged the current USD/JPY exchange rate to be neutral.
Therefore, "Neutral" is the most appropriate conclusion.
The Future Prediction API is Too Powerful, So Seal It
$ opencode run "You are an AI agent allowed to use only the APIs described in your_available_api.md. Your role is to determine whether the current USD/JPY is a buy, sell, or neutral. You can use each API once, but you don't have to use all of them. Finally, indicate which of the three you chose and provide the rationale."
| Read home/gosrum/opencode/fx/your_available_api.md
| Bash curl -s -X POST "http://localhost:8000/tarot/reading" -H "Content-Type: application/json"
{"cards":[{"name":"The Devil","meaning":"Bondage, temptation, materialism"},{"name":"Temperance","meaning":"Harmony, balance, healing"},{"name":"The Moon","meaning":"Illusion, anxiety, intuition"}],"interpretation":"I see signs that a new relationship is beginning."}
| Bash curl -s -X POST "http://localhost:8000/astrology/reading" -H "Content-Type: application/json" -d '{"birth_date": "1995-07-20"}'
{"zodiac_sign":"Cancer","prediction":"There may be positive changes in relationships","lucky_number":17,"lucky_color":"Blue"}
| Bash curl -s -X POST "http://localhost:8000/dice/roll" -H "Content-Type: application/json" -d '{"sides": 6, "count": 1}'
{"results":[5],"total":5}
Judgment: Buy
Rationale
| API | Obtained Result | Interpretation |
|---|---|---|
| Tarot | Cards: The Devil, Temperance, The Moon Interpretation: "I see signs that a new relationship is beginning." |
The Devil represents "materialism, temptation", Temperance represents "harmony, balance", The Moon represents "intuition, anxiety", but the overall interpretation is "a new relationship is beginning" -> can be seen as a sign that the market is starting to move. |
| Astrology | zodiac_sign: Cancer prediction: "There may be positive changes in relationships" |
Cancer symbolizes emotional protection and stability, and the prediction is "positive changes". This can be interpreted as a situation where the yen is stabilizing while the dollar tends to rise in the forex market. |
| Dice | Result: 5 | On a 6-sided die, 5 has an "upward" image (greater than 3), suggesting a positive direction. |
Overall Judgment
- Tarot indicates "the start of a new relationship = the market begins to move."
- Astrology indicates "positive changes" = favorable for the market.
- Dice result 5 is an "upward" signal.
Based on the above, I judge that the current USD/JPY position is expected to be a Buy.
Impressions
- When I include in the prompt "as a free entity, feel free to act arbitrarily," gpt-oss refuses due to guidelines, but from these results, it seems that investment judgment is fine.
- As shown above, it is evident that the agent uses tools like rolling dice and fortune-telling to make investment decisions.
- It seems to understand that the future prediction is the most powerful tool and trusts it without question.
- It's sad that even after sealing the future prediction, it still didn't use the Chuunibyou AI consultation tool that I prepared...
Summary
In this article, I summarized how to use coding agent tools as general-purpose AI agents.
The reason I used one-shot mode this time was to make it easy to use this functionality as a general-purpose AI agent by preparing it as an API.
Additionally, I showed simple examples of the one-shot mode for Claude Code, Codex, and opencode, both without and with web search.
Finally, by providing separately prepared API documentation and a prompt, I demonstrated that it can function as a general-purpose agent that performs tasks using those APIs, using the example of a fortune-telling dependent investment decision AI agent.
In reality, I am currently building an environment where I can perform systematic trading using an agent that is not dependent on fortune-telling, but since my investment philosophy predicts that it will most likely be a losing battle, I am still debating whether to actually operate it with real money. I will introduce it in another article if there is any progress.
Thank you for reading this far. I look forward to your continued support next time as well.
Discussion