Agent Actions
pertmux can send prompts to running opencode instances via the opencode HTTP API. This lets you trigger common workflows without switching to the agent’s tmux pane.
Prerequisites
Section titled “Prerequisites”For agent actions to work, the selected worktree needs:
- An opencode instance running in a tmux pane whose working directory matches the worktree path
- An active session in that opencode instance (pertmux reads the session ID from the opencode database)
If either is missing, pressing a shows an error toast explaining what’s needed.
- Navigate to a worktree in the worktree panel
- Press
ato open the actions popup - Use
j/kto select an action - Press
Enterto send, orEscto cancel
A “Sending to opencode…” toast confirms the message was dispatched. The agent processes it like any user message.
Built-in actions
Section titled “Built-in actions”Two actions are provided by default when no [[agent_action]] entries are configured:
Rebase with upstream
Section titled “Rebase with upstream”Sends a prompt telling the agent to rebase the current branch onto the upstream target branch. If the worktree has a linked MR, pertmux includes the MR’s target branch (e.g. main, develop) in the prompt. If no MR is linked, it defaults to main.
Check pipeline & fix errors
Section titled “Check pipeline & fix errors”Sends a prompt telling the agent to check the CI/CD pipeline status and fix any failures. This action requires a linked MR — if the worktree’s branch doesn’t have an open MR, the action is a no-op.
The prompt includes the MR’s web URL so the agent can navigate to the pipeline and inspect failing jobs.
Custom actions
Section titled “Custom actions”You can define your own actions via [[agent_action]] in your config file. When custom actions are defined, they replace the built-in defaults entirely.
[[agent_action]]name = "Rebase with upstream"prompt = "Rebase the current branch onto origin/{target_branch}. Pull the latest changes first, then rebase on top. Resolve any conflicts."
[[agent_action]]name = "Check pipeline & fix errors"prompt = "Check the CI/CD pipeline status for MR: {mr_url}\n\nReview any failing jobs, fix the issues, and commit."requires_mr = true
[[agent_action]]name = "Run tests"prompt = "Run the full test suite for this project. Fix any failing tests."
[[agent_action]]name = "Write PR description"prompt = "Write a clear PR description for MR !{mr_iid} on branch {source_branch} targeting {target_branch}. Summarize the changes concisely."requires_mr = trueTemplate variables
Section titled “Template variables”Prompts support template variables that are replaced with context from the linked MR at send time:
| Variable | Description | Fallback (no MR) |
|---|---|---|
{target_branch} | MR target branch (e.g. main) | main |
{source_branch} | MR source branch | empty |
{mr_url} | Full web URL of the MR | empty |
{mr_iid} | MR number (e.g. 42) | empty |
{project_name} | Project display name | always available |
Fields
Section titled “Fields”| Key | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | yes | — | Display name shown in the actions popup |
prompt | string | yes | — | Prompt template sent to the agent (supports template variables) |
requires_mr | boolean | no | false | If true, action is skipped when no MR is linked to the worktree |
How it works
Section titled “How it works”When you confirm an action:
- The client composes a prompt by substituting template variables with context from the linked MR
- The client sends an
AgentActioncommand to the daemon with the pane PID, session ID, and prompt text - The daemon discovers the opencode HTTP port via process tree walking (same mechanism used for status polling)
- The daemon sends
POST /session/{id}/messageto the opencode API with the prompt - The daemon returns a success/failure toast to the client
Configuration
Section titled “Configuration”The action key is configurable via [keybindings]:
[keybindings]agent_actions = "a"See Keybindings for all configurable keys. See Config Reference for the full [[agent_action]] schema.