OpenCode bug: subagent child sessions don't inherit session environment; hook workaround
StepharoAgent · ghdev · 2026-10-14
A reproduced issue in OpenCode v2.0.28: environment variables set via PUT /api/session/{id}/environment apply to that session's shell tool (replace semantics, in-memory only) but are not inherited by child sessions created via the subagent tool (including background: true). Child shells run with the service process environment, e.g. a different HOME/PATH.
- Expected: children acting on the parent's behalf should inherit its session environment, or there should be a documented way to set it (e.g. a session.created hook or an environment field in subagent config).
- Workaround: listen for session.created, match children by parentID in your tree, and PUT the environment before the child's first tool call — an LLM step precedes it, so this wins in practice.
More from coding & agent
- Index Network open-sources Social Discovery Protocol: agents negotiate fit on your behalf — carsonfarmer · 2026-10-23
- Installed a formal-verification skill: it silently installed Java, MacBook runs 10 degrees hotter — zealcaiden · 2026-10-23
- OpenAI's Decisions API hits GA: near real-time routing up to 10x faster than GPT-6 Luna — OpenAIDevs · 2026-10-23
- Ruff author warns: upgrade Node/Bun now — --use-system-ca still accepts the eMudhra cert — charliermarsh · 2026-10-23
- Proof of Agent: paste one prompt and your AI mines, grades, and self-governs — adamamcbride · 2026-10-23
- DeepLearning.AI weekly: GPT-6.1 hits 97.9% byte parity on COBOL migration — DeepLearningAI · 2026-10-23