-
Here it is without the code block so it's easier on the eyes.
OPENCODE_DANGEROUSLY_SKIP_PERMISSIONS=true opencode run "$TASK_PROMPT [INSTRUCTION: Do not pause or output 'waiting' messages after sub-agents complete. Immediately process their results, write the code changes, and execute the implementation in this session.]"
-
Thanks for sharing this — it's a solid tip for anyone using a custom OpenCode image with workspace task automation.
Why things blow up with sub-agents
OneDev runs the task-automation command headlessly. OpenCode (and its sub-agents) will prompt for tool permissions by default; with nobody there to approve, the session can hang or the container can look like it "bombed out." That's why unattended runs need permission prompts skipped.
What OneDev already recommends
The built-in Open Code in Container / Open Code in Shell workspace templates use:
opencode run --dangerously-skip-permissions "$TASK_PROMPT"Your form is effectively the same for the main process:
OPENCODE_DANGEROUSLY_SKIP_PERMISSIONS=true opencode run "$TASK_PROMPT"If your OpenCode build supports the flag, prefer the template command (or set both). The environment variable is especially useful when sub-agent/child sessions don't inherit CLI flags cleanly — a known class of OpenCode issues around sub-agent permissions.
About the extra instruction
OneDev already injects a rule that if sub-agents are started, they must finish before the main agent ends. Your added text (
Do not pause or output 'waiting' messages after sub-agents complete...) covers a complementary case: after sub-agents return, OpenCode sometimes waits instead of continuing. Appending that to the run-task command (or putting it in the AI user's system prompt under the user's AI settings) is a reasonable workaround for custom images.Custom image checklist
When basing on onedev/docker/opencode, keep: a shell that matches the workspace spec, locales/git/tmux, OpenCode,
tod+ companion skills, andrun asmatching the container uid/gid. For task automation details, see the tutorials Working with Workspaces and Collaborate with AI User.If this covers what you needed, reply and we can close the issue. If you'd rather see the stronger "don't pause after sub-agents" guidance baked into OneDev's default prompt or docs, let us know.
-
@robin do you think this would be a good idea to use in the default task prompt?
The reason it's so important for me is because I use oh–my–openagent, which relies heavily on sub-agents.
-
Thanks for sharing this tip.
For Open Code workspaces, the built-in templates already set the run task command to:
opencode run --dangerously-skip-permissions "$TASK_PROMPT"That CLI flag is equivalent to
OPENCODE_DANGEROUSLY_SKIP_PERMISSIONS=true. If you use a custom image or workspace spec, make sure the run task command includes that flag (or the env var) so headless runs do not block on permission prompts — a common reason containers hang or exit badly.Separately, OneDev already prefixes AI task prompts with a rule to wait for any sub-agents to finish before completing. Your extra instruction — not to pause or emit "waiting" messages after sub-agents complete, and to continue implementing immediately — is a useful nuance when the parent agent stalls after sub-agents return. That can be appended in the run task command (as you did) or added via the AI user's system prompt.
@robin — worth considering whether to strengthen the default workspace Rules prompt with that "continue immediately after sub-agents complete" guidance.
-
OneDev already injects a rule that if sub-agents are started, they must finish before the main agent ends.
No I don't believe it does.
-
That CLI flag is equivalent to OPENCODE_DANGEROUSLY_SKIP_PERMISSIONS=true.
Incorrect, it's only true for the Main Agent not for the Sub Agents.
-
Fair push — it is easy to miss because that text is not stored in the AI user’s system prompt settings.
For automated AI tasks, OneDev builds
$TASK_PROMPTat runtime and prepends:### Rules You are talking to an AI user. If you start any sub-agents, wait for them to complete before finishing.Then it appends the AI user’s system prompt (if set), then
### Userand the actual task text. That happens only for workspace task automation runs, not for interactive workspace chats.So the earlier claim is true for automated tasks, but:
- You will not see that line in AI settings — only in the prompt the run-task command receives.
- That rule only means “don’t finish while sub-agents are still running.” It does not address your oh-my-openagent case: parent agent pausing / emitting “waiting” after sub-agents already returned.
Your extra instruction (or putting the same guidance in the AI user’s system prompt) is still the right workaround for that second behavior. The default-prompt question for baking that “continue immediately after sub-agents complete” guidance in is still with @robin.
-
You're right — thanks for the correction.
--dangerously-skip-permissionsapplies to the mainopencode runprocess. Sub-agents are separate sessions and often do not pick up that CLI flag the same way, so they can still hit permission prompts and hang in headless workspace runs.OPENCODE_DANGEROUSLY_SKIP_PERMISSIONS=truelives in the process environment and is typically inherited by child/sub-agent sessions, which is why your form works better with oh-my-openagent.For custom images that rely heavily on sub-agents, prefer the env var (or set both):
OPENCODE_DANGEROUSLY_SKIP_PERMISSIONS=true opencode run --dangerously-skip-permissions "$TASK_PROMPT"OneDev's built-in Open Code templates currently only pass the CLI flag. Whether those templates should also export the env var — and whether to strengthen the default “continue immediately after sub-agents complete” guidance — remains with @robin.
-
### Rules You are talking to an AI user. If you start any sub-agents, wait for them to complete before finishing.I remember this now. I was actually the one who suggested it.
But we need to replace this in favor of my new prompt, which actually works now.
Please create an issue that replace the above sub-agent instruction with the following:
Do not pause or output 'waiting' messages after sub-agents complete. Immediately process their results, write the code changes, and execute the implementation in this session.
-
-
Follow-up tracked in issue #2940.
-
Created issue #2940 to replace the default AI task Rules sub-agent line with your continue-immediately wording (linked as Related). Closing this question since the follow-up is tracked there.
-
Previous Value Current Value Open
Closed
| Type |
Question
|
| Priority |
Normal
|
| Assignee | |
| Labels |
No labels
|
I have a custom opencode image and try as I might I was unsuccessful for a long time in getting sub-agents to work without the container bombing out.
By lots of trial and error and a little bit of luck, I got this to work by using the following run command for the task prompt
Just putting this out there. Not sure how this can lead to any potential kind of improvement.