---
name: codemode-how-to-self-improve
description: "Reload Po's own packages, or refresh this session's mode, domain and profile config, after you edit them, without restarting Po or reopening the session. Use in Help mode after changing a plugin, adding or removing a package, or editing presets.yaml, a domain or a profile."
---

# Reload Po packages with `selfImprove`

`selfImprove` exists only in Help mode, only for the main agent, and only on hosts that can reload (not the edge). Run `discover({ namespace: 'selfImprove' })` for signatures.

## Where to work

- Develop and test plugins in **workspace** scope. A workspace reload touches only this workspace's sessions.
- Leave host plugin files alone unless the person asked. Po already picks up saved changes to them, so an edit there reaches every session at once.
- A reload loads what is on disk. Build the package first; `selfImprove` never runs `npm install` or a build.
- A reload after a web plugin changed starts a background sync that rebuilds the web app. Server code is live when the operation applies; open clients swap to the new UI when that sync finishes, usually within a minute, with no page reload.
- In a `--test` instance (Po running from its own checkout) nothing picks up package edits on its own, host ones included. Build, then reload the scope that selects the package, usually `host` there.

## Reloading

1. `selfImprove.reload({ scope })` returns `{ operationId, state: 'queued' }` at once. A session reload applies after the current tool round ends, so do not wait for it in the same `exec`. End the round; do not tell the person it is merely queued.
2. When it finishes, Po sends you a follow-up message with the outcome. Pass it on to the person without being asked. `selfImprove.operation(operationId)` returns the same outcome in a later `exec`:
   - `applied`: every package installed. Installed packages no longer declared were removed (`result.removed`).
   - `partial`: some packages failed (`result.failed`) and keep their previous build when they had one.
   - `failed`: nothing changed; `error` says why.
3. The model sees new tools on its next request. Old tool handles from before the reload are refused.

`scope: 'host'` changes every session. Ask the person first (for example with `ask_user_question`), and pass `confirm: true` only after they agree. Without it the call is refused and nothing is queued.

## Refreshing config

After editing `presets.yaml`, a domain, or a profile's env or binding, call `selfImprove.refresh({ axes })` with any of `'preset'`, `'domains'`, `'profile'` (default: all three). It re-applies the session's current names from disk, so no rename or reopen is needed. It is queued like a reload, applies after the current tool round, and reports its outcome the same way. A `profile` refresh reconnects its secret provider.

Domain code-mode scripts load once when the session opens; a new or changed domain script needs the session reopened.

## Checking health

`selfImprove.plugins()` lists packages whose current build failed to load or install, by scope, with the reason and whether the previous build still runs. Read it before and after a reload instead of guessing from missing tools.

## Mistakes to avoid

- Calling it from a subagent: refused. Do the reload in the main agent.
- Retrying in a loop: one failure means fix the code or build, then reload once.
- Presenting a restart as a reload: if a change needs a restart (provider overrides, MCP plugins), tell the person and let them reopen the session.
