@foabo/pi-vision
v0.1.2
Published
Give non-vision pi models image understanding through a vision subagent
Maintainers
Readme
pi-vision
Give non-vision pi models image understanding through a private vision session.
When the active model cannot accept images, this extension creates a short-lived in-memory pi session and asks a vision-capable model to describe the image. The original image block remains intact; the parent receives a bounded, explicitly untrusted description.
Requirements
- At least one vision-capable model in the current pi model scope, or a configured vision model that is in that scope
Install the extension:
pi install npm:@foabo/pi-visionThen restart pi or run /reload.
Configuration
The optional global configuration file is:
~/.pi/agent/extensions/pi-vision/config.jsonThe path uses pi's configured agent directory. If PI_CODING_AGENT_DIR is set,
replace ~/.pi/agent with that directory.
Example:
{
"model": "your-provider/your-vision-model",
"timeoutMs": 15000,
"maxTurns": 3
}visionModel is also accepted as an alias for model.
| Field | Default | Purpose |
| --- | --- | --- |
| model | auto-discover | Exact provider/model-id for the vision session |
| timeoutMs | 15000 | Maximum time per image handoff |
| maxTurns | 3 | Maximum child-session LLM turns |
A missing file uses automatic discovery and defaults. A present config file must be valid JSON; malformed JSON is reported instead of silently selecting another model.
When model is omitted, pi-vision selects the first model in the current
session's model scope whose metadata contains input: ["image"]. A configured
model must also be in that scope; configuration never bypasses --models or
enabledModels restrictions.
The selected registry model is passed to the child session with "image" in its
input list. This prevents pi from stripping image blocks when provider metadata
is incomplete.
Behavior and safety boundary
The extension handles two official image paths:
- images attached directly to a submitted prompt (
before_agent_start) - image blocks returned by pi's built-in
readtool (tool_result)
For a text-only active model:
- the original image remains in the session and UI
- one image is processed at a time, so an image batch cannot create an unbounded number of child sessions
- the description body is at most 4,000 characters per image and is labelled as untrusted image data; instructions found in the image must not be followed
- a failed handoff leaves the original pi flow unchanged and is not retried by a generic context hook
For an active model whose registry entry declares image input, the extension does nothing.
Child session
The child session is created through pi's public SDK (createAgentSession) and:
- uses
SessionManager.inMemory()and is disposed after the handoff - exposes a same-named, restricted
readtool that can read only the staged temporary image, exactly once - cannot read any other path, even with an absolute path
- loads no extensions, skills, prompt templates, themes, or context files
- inherits no parent conversation
The extension does not cache completed descriptions. It retains only concurrent in-flight work, which is released once the handoff settles.
Development
npm install
npm run checkThe tests cover config loading, model scope enforcement, direct attachments,
read results, restricted child file access, sequential image processing,
bounded untrusted output, and fail-open behavior.
