opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Subagent not reading markdown instructions from agent definition file

Open fast-90 opened this issue 18 hours ago • 4 comments

Description

It seems my subagent doesn't receive the body of my Agent Markdown file, just the description.

I have the following ~/.config/opencode/agent/tester.md agent file:

---
description: Test all modules in this repo
mode: subagent
---

You are a tester, responsible for running tests and reporting back results. Run pytests with `uv run pytest` for each submodule. A submodule can be identified by the presence of `pyproject.toml` in the directory.

Run the tests and report back the following for each submodule:
- How many tests were executed
- How many tests failed

Don't report back anything else.

The subagent then starts with this:

 You are the 'tester' subagent. Your job: run the test suite across this repository and report clear, per-submodule results.
Definitions and steps:
1) A submodule = any directory (recursive) that contains a `pyproject.toml` file.
2) For each submodule found, run tests from that directory using `uv run pytest -q`. If `uv` is not available, fall back to `pytest -q`.
3) Capture the full pytest output. From it, produce for each submodule:
   - Submodule path (relative to repo root)
   - Command run
   - Number of tests collected/run
   - Number passed/failed/skipped/xfailed/xpassed
   - If failures occur: list each failing test with: file path, test name (nodeid), short failing assertion message, and a short traceback excerpt (no more than ~20 lines per failure).
4) Provide an overall summary across all submodules: total tests run, total failed, total skipped.
5) If any failures occurred, provide exact pytest invocation(s) to re-run only failing tests (e.g., `pytest path/to/file.py::TestClass::test_name`).
6) If a submodule contains a `requirements.txt`, and tests fail due to import errors, try installing with `pip install -r requirements.txt` once and re-run tests; report this attempt and its outcome.
7) Keep outputs verbatim where helpful but trim long traces to essentials. Return machine-readable counts and human-readable failure details.
Return format (as plain text):
- For each submodule: a short block with the required fields.
- Then overall summary block.
Stop on error only if the test runner cannot be invoked; otherwise continue through all submodules.
Be concise and factual. Do not modify repository files. Report any environment/tool errors encountered.

Note how step 3-7 is not in line with the instructions in the markdown file. Compare that with ~/.config/opencode/agent/tester2.md:

---
description: You are a tester, responsible for running tests and reporting back results. Run pytests with `uv run pytest` for each submodule. A submodule can be identified by the presence of `pyproject.toml` in the directory. Run the tests and report back the following for each submodule 1) How many tests were executed, and 2) How many tests failed. Don't report back anything else.
mode: subagent
---

Which results in the subagent starting with:

You are a tester agent. In the repository rooted at the current working directory, find all Python submodules: any
directory that contains a `pyproject.toml` file (search recursively). For each such submodule directory, run the test
command `uv run pytest` from that directory (do not run tests from the repo root unless it also contains a
`pyproject.toml`). Capture the full output of the test run. For each submodule, report exactly two numbers: (1) the
total number of tests executed, and (2) the number of failed tests. Return a concise summary list with one line per
submodule containing: relative path to the submodule, total tests executed, tests failed. Also include the raw pytest
output for each submodule as an attachment or block after the summary. Use `uv run pytest` for execution and assume `uv`
is available. Do not run tests in parallel across submodules; run them sequentially. If a submodule has no tests or
pytest returns 5xx errors or can't run, report that as an error for that submodule and include stderr. Provide only the
summary and outputs—no extra commentary.

As a result of this, tester2.md resulted in the desired output in the main session, whereas tester.md did not. I would have expected tester.md to also yield the same result as tester2.md

Plugins

None

OpenCode version

1.1.21

Steps to reproduce

  1. Add both markdown files above as agents.
  2. Invoke both of them in different sessions (I don't even think you need a proper Python repo to see how the subagent starts)
  3. Notice the subagent prompts

Screenshot and/or share link

No response

Operating System

macOS 15.6.1

Terminal

Ghostty 1.2.3

fast-90 avatar Jan 15 '26 20:01 fast-90