# pi-autoprompt

English | [한국어](./README.ko.md)

pi-autoprompt makes Pi include direct goal-continuation follow-up task candidates in the final assistant response, then lets you select one after the session turn ends or automatically continues after a timeout. It does not make an extra LLM call. If there is no useful immediate follow-up work, it stops.

## Commands

```text
/autoprompt on                 # Enable automatic follow-up execution and loop mode
/autoprompt off                # Disable automatic follow-up execution for the current runtime
/autoprompt now                # Run autoprompt once now
/autoprompt status             # Show current status (default timeout=10s)
/autoprompt timeout 15         # Set selection timeout in seconds
/autoprompt loop on            # Enable continuous follow-up execution
/autoprompt loop off           # Disable continuous follow-up execution for the current runtime
/autoprompt mode normal        # Suggest practical follow-ups that continue the current goal
/autoprompt mode conservative  # Suggest only follow-ups required to finish the explicit request
/autoprompt cancel             # Cancel the pending automatic follow-up
/autoprompt history            # Show recent automatic follow-up history
/autoprompt help               # Show command help
/autoprompt doctor             # Show cache decision / usage debug info
/autoprompt reset-stats        # Reset cache statistics
```

## Loop

Autoprompt and loop mode are default-on after startup/reload. After an autoprompt follow-up finishes, if the final response contains more goal-continuation follow-up candidates, pi-autoprompt keeps sending the next selected candidate.

The current loop stops automatically when there is no useful immediate follow-up task.

If `cacheRead` is missing or the prompt cache hit rate is below 50%, pi-autoprompt shows a warning but keeps the loop running while follow-up candidates exist.

When there is no useful immediate follow-up task, pi-autoprompt stops the current loop but keeps the saved loop setting enabled for future turns.

## Doctor

`/autoprompt doctor` shows cache debugging values in one report:

- `currentCacheKey`, `sessionId`
- `lastRawUsage`
- Extracted `cacheRead`, `cacheWrite`, `totalInputTokens`
- `cacheHitRate`
- Hints for possible causes when `cacheRead=0`

## Persisted settings

The following values are stored under `piAutoprompt` in Pi's global `settings.json`, so they survive `/reload`:

- `timeoutSeconds`
- `mode`
- `history`

`enabled` and `loopEnabled` are intentionally default-on after startup/reload. Use `/autoprompt off` or `/autoprompt loop off` to disable them for the current runtime.

## Cost note

`loop on` can keep the coding agent running through multiple follow-up tasks. Turn it off with `/autoprompt loop off` when needed.
