Environment
- opencode 1.18.23 and 1.18.25 (verified on both)
opencode serve --port 4200 --hostname 127.0.0.1 on Linux
- custom project agents in
.opencode/agents/*.md (tools as an object map, e.g. read: true)
- API use:
POST /session/{id}/message with agent: <id>
Reproduction
- Start
opencode serve in a project that defines a custom agent (.opencode/agents/my-agent.md).
- Create a session and send a message with
"agent": "my-agent" — answers normally.
- While the server is LIVE, rewrite the agent file (any change — e.g. regenerating it from a build step).
- Send another message with
"agent": "my-agent".
Actual
Every subsequent ask returns HTTP 200 with empty text and zero output tokens, indefinitely. No error is logged server-side, no error surfaces to the client, and the state never recovers. The only remedy is a full server restart (verified: new pid required — killing by a stale pid file while the old listener still holds the port silently keeps the poisoned state).
Expected
Either the rewritten agent definition takes effect, or the previous one keeps serving — not a permanent silent empty-response state.
Why this matters
The empty-200-with-zero-tokens signature is indistinguishable from the provider-error-swallowing symptom already tracked in #41469 (session silently stops on empty LLM response), which makes diagnosing this state much harder than it should be — a poisoned agent looks exactly like a dead provider key. We run a 35-agent fleet against one shared opencode serve (agents generated from a build pipeline), and an agent regeneration mid-flight silently zeroed a whole evaluation run before we traced it to this.
Workaround we adopted: byte-compare before writing agent files (no change, no write) and do a verified restart (real listener resolved via ss, port actually freed, new pid != old pid) after any agent-file change.
Related
Happy to provide more detail (request/response captures, agent frontmatter, server logs) if useful.
Environment
opencode serve --port 4200 --hostname 127.0.0.1on Linux.opencode/agents/*.md(tools as an object map, e.g.read: true)POST /session/{id}/messagewithagent: <id>Reproduction
opencode servein a project that defines a custom agent (.opencode/agents/my-agent.md)."agent": "my-agent"— answers normally."agent": "my-agent".Actual
Every subsequent ask returns HTTP 200 with empty text and zero output tokens, indefinitely. No error is logged server-side, no error surfaces to the client, and the state never recovers. The only remedy is a full server restart (verified: new pid required — killing by a stale pid file while the old listener still holds the port silently keeps the poisoned state).
Expected
Either the rewritten agent definition takes effect, or the previous one keeps serving — not a permanent silent empty-response state.
Why this matters
The empty-200-with-zero-tokens signature is indistinguishable from the provider-error-swallowing symptom already tracked in #41469 (session silently stops on empty LLM response), which makes diagnosing this state much harder than it should be — a poisoned agent looks exactly like a dead provider key. We run a 35-agent fleet against one shared
opencode serve(agents generated from a build pipeline), and an agent regeneration mid-flight silently zeroed a whole evaluation run before we traced it to this.Workaround we adopted: byte-compare before writing agent files (no change, no write) and do a verified restart (real listener resolved via
ss, port actually freed, new pid != old pid) after any agent-file change.Related
Happy to provide more detail (request/response captures, agent frontmatter, server logs) if useful.