Profiles and models

An agent is a Markdown file. Choosing a model, signing in to ChatGPT, and thinking levels.

beginner11 min read

Open a new chat and pick Developer. The same composer is still in front of you, but the next reply can follow a different set of instructions and come with a different set of tools. You’ll find the reason in a Markdown file short enough to read before you send the first message.

In this chapter

  • Read the settings and instructions in a bundled profile.
  • Follow a profile into a new chat and see when a saved chat picks up edits.
  • Choose a model and a thinking level in Runtime settings.
  • Follow ChatGPT sign-in from the browser back to the host.

Developer starts as a Markdown file

Developer’s profile
---
id: developer
name: Developer
optional_extensions: [
  pipal.workspace, pipal.web-artifacts,
  pipal.coding, pipal.bash,
  pipal.web-search, pipal.public-web]
delegates: [reviewer]
---
Help the user implement features
and fix bugs.
agents/developer.md
  1. Identity

    Pipal saves the ID in a conversation. The name is what you see in the profile picker.

  2. Optional extensions

    Each name refers to a bundle of capabilities. Pipal filters optional names against the host’s enabled list. Routed project tools also depend on the chat’s workspace.

  3. Specialist

    In a top-level Developer chat, the reviewer ID names the one specialist the profile may call when delegation is enabled.

  4. Instructions

    The Markdown body supplies the instructions for the chat. Farther down, Developer is told to publish a requested patch as soon as it is ready, then verify it and report what passed or remains.

---







---

agents/developer.md

1 Identity

Pipal saves the ID in a conversation. The name is what you see in the profile picker.

Select each part of agents/developer.md. The Markdown instructions begin below the second divider.

A profileA named set of instructions, defaults, and tool grants that Pipal applies to a conversation. is Pipal’s recipe for a conversation. Look in agents/ beside the configuration file. The part between the two --- lines is frontmatter, settings written as YAML. The Markdown below it tells the model how to approach the job. Developer’s instructions begin with implementing features and fixing bugs, then ask it to trace the relevant definitions, callers, and tests. developer.md

The four bundled files give you four starting points. Chat answers general questions and can hand off live host checks, project work, and reviews. Developer investigates problems and implements changes. chat.md developer.md

Sysadmin measures the computer running Pipal, using host diagnostics when they’re available. Code reviewer starts from a patch or supplied files and looks for defects and regressions. These roles come from the written instructions, so a new review can use the same model as the chat it follows. sysadmin.md reviewer.md

Developer’s optional_extensions names bundles it can use when the host enables them. Tools and extensions follows those permissions from the configuration file to a tool call. Its delegates list gives it a route to Code reviewer, covered in Delegation. developer.md

Among the bundled profiles, Chat and Developer request pipal.web-search. It lets a compatible model search through its provider. Developer also requests pipal.public-web, an independent grant for two keyless host tools. Both web extensions are off by default. The operator lists the desired grants in extensions.enabled and restarts Pipal. An explicit list replaces the defaults. config.example.toml config.ts

Developer’s instructions favor hosted search for public documentation. The profile suggests search_public_web as a fallback and read_url for a specific public HTTPS page. The first sends search terms to Exa. The second sends the URL to Jina Reader. Either web extension can work in a Docker chat while Bash and ordinary file calls stay offline. developer.md public-web.ts

Deep diveWhat makes a profile fail at startup

loadProfiles() reads the .md files in filename order, which also gives Pipal the default profile when no ID is supplied. The parser requires a valid id and a nonblank name. If either provider or model is present, both must be nonblank strings. The ID starts with a lowercase letter, has at most 64 characters, and then allows lowercase letters, digits, underscores, and hyphens. Unknown keys, YAML aliases, malformed frontmatter, an unreadable directory or profile file, duplicate profile IDs, and a directory with no Markdown profiles fail loading. profiles.ts index.ts

The remaining keys are extensions for required bundles, optional_extensions for conditional bundles, delegates for specialist IDs, max_turns for a positive safe integer cap, and thinking_level for a recognized level. Extension lists take nonblank strings and names must be distinct across both lists. Delegate IDs follow the profile ID rules and must be distinct. Core checks that every delegate target exists, even with delegation disabled. Before opening the harness it runs settings() for each profile without a bound workspace. An unavailable model, an incompatible thinking level, or an extension that this calculation selects but that did not load fails startup. profiles.ts index.ts

A profile selecting both pipal.coding and pipal.project-read fails startup. If a workspace fails its startup probe, loadWorkspaceLocations() logs the failure and keeps it selected. For a location marked Unavailable after a backend probe fails, the owner can use Retry connection in Settings → Workspace. grants() leaves the routed project extensions out of a chat when its workspace is unavailable. workspace-locations.ts DeveloperWorkspace.svelte index.ts

A chat saves the settings it will use

In a new Developer chat, open Runtime in the composer. When there is a choice of where to work, the Location field lets you pick a locationThe place a chat uses for project tools, either the Pipal host, an account reached over SSH, or a Docker project.. The available destinations come from Settings → Workspace and can include This machine, SSH machine, or Docker. Runtime shows the same shell network hint as Settings when Docker is selected. For a location that supports creating projects, Project is a text field with suggestions. Pick an existing name or type a new one to create the folder on the first send. The chip shows the destination, for example This machine · pipal-scratch. RuntimePicker.svelte workspace-choice.ts

When Pipal creates the conversation, it writes the settings Pi will use into pi.agent: the model, the instructions, the thinking level, the cap on turns, and the selected extension names. In pipal.chat it records the profile ID and pins the location and any project. Both writes belong to one commit, so the first reply starts with a complete set of settings. To work in a different location or project, start a new chat. index.ts

Selecting a profile for an existing chat reapplies its settings against the pinned location and can change the model. The composer’s Runtime settings show the applied choice. A specialist gets its own profile’s settings and uses the parent’s model unless the specialist profile pins one. index.ts

If you edit a profile on the host, restart Pipal to load the file. On the next accepted message, a saved chat on that profile gets the current instructions and extension selection, including the internal turn-budget hooks that warn the model and reserve a final answer. Its model, thinking level, and turn cap stay with the chat. An older Developer chat saved at 20 can therefore get the warnings and still run with its old cap, even when a new Developer chat gets 50. main.ts index.ts

To apply the current cap, apply the profile again. In Runtime → Profile, choosing another profile applies its settings, and switching back reapplies the original profile. Check the model and thinking level afterward, since switching profiles can change them too. The core runtime explains what the cap counts. RuntimePicker.svelte index.ts

Deep diveWhich settings Pipal applies and which it refreshes

GET /api/v1/profiles returns locations and defaultLocation for a profile with workspace tools or, when delegation is enabled, access to a specialist with those tools. The list includes enabled locations, with unavailable: true when one has no open backend and project fields where the location supports them. The top-level workspace, projects, and canCreateProjects describe the default location when it is available. app.ts index.ts

settings() takes the request’s model, the profile’s pin, or the registry’s default, in that order. It saves the lower of the profile’s max_turns and the applicable runtime cap in pi.agent.maxTurns. The 50-round default is keyed to the ID developer on a top-level chat. Other top-level chats and foreground specialists default to 20. A configured runtime.max_turns replaces both defaults, and an independent worker uses runtime.worker_max_turns. Pi counts tool roundsA model response that requests tools, together with the tool calls it requested. against the saved cap. index.ts README.md

A PATCH /api/v1/conversations/:id naming a profile runs the full settings calculation, even if it names the saved profile ID. You can include a model and thinking level in the same request. A PATCH with model or thinking level fields alone recalculates only those two settings. Pipal returns HTTP 409 for runtime settings changes during a run. app.ts index.ts

savedChatChange() recalculates instructions, ordered extension names, and the filter for tools the pinned location cannot run. The shared admission transaction for a new message, routine prompt, or Resume applies any difference and leaves maxTurns as saved. If a profile has been removed, the chat retains its last instructions and receives an empty extension selection. index.ts

The model picker shows what this host can use

Four ways to get a reply
FeatureLocal echo ChatGPT OpenAI API DeepSeek API
How it becomes availableAvailable at startup.Connect ChatGPT from Pipal.Set an OpenAI model and API key on the host.Set a DeepSeek model and API key on the host.
What the picker getsfaux/faux-1.Listed account models that Pi supports. The host refreshes the saved list as access changes.One configured OpenAI model.One configured DeepSeek model.
Where the reply runsOn the Pipal host.OpenAI, using the connected plan.OpenAI, using the API key.DeepSeek, using the API key.

Choose up to two columns

Choose up to two columns

FeatureLocal echo ChatGPT OpenAI API DeepSeek API
How it becomes availableAvailable at startup.Connect ChatGPT from Pipal.Set an OpenAI model and API key on the host.Set a DeepSeek model and API key on the host.
What the picker getsfaux/faux-1.Listed account models that Pi supports. The host refreshes the saved list as access changes.One configured OpenAI model.One configured DeepSeek model.
Where the reply runsOn the Pipal host.OpenAI, using the connected plan.OpenAI, using the API key.DeepSeek, using the API key.
Compare the choices by what you configure and where the reply runs. The two OpenAI columns are alternate modes for the same installation.

Start with Local echo to see the chat work with no provider account. It sends back the text of your last user message after the prefix Local echo:, from inside the host process. Pipal gives each choice in its model registryThe collection of models Pipal can select for a conversation, addressed by provider and model ID. an address of the form provider/modelId, so the ID for Local echo is faux/faux-1. models.ts

To use OpenAI in API-key mode, the operator sets runtime.openai_model and supplies OPENAI_API_KEY in the host environment. That makes the configured model the only OpenAI entry in the picker and disables ChatGPT sign-in. If you supply the key alone, the host stays in ChatGPT mode and gets its OpenAI choices from a connected account. An optional runtime.deepseek_model and DEEPSEEK_API_KEY add one DeepSeek model alongside either mode. models.ts config.ts

For a new top-level chat, an explicit model choice takes priority over the profile’s provider and model pin. All four bundled profiles leave the pin out. Without either choice, Pipal takes the first connected ChatGPT model that matches the Pi catalog, then a configured OpenAI API model, then a configured DeepSeek model, and finally Local echo. index.ts models.ts

For a reasoning model, open Thinking in Runtime settings. A thinking levelA setting that asks a compatible model to use a particular level of reasoning effort. tells Pi what effort to request for the model’s reasoning. The picker offers the levels the current model supports, plus Auto, which leaves the choice to Pi. If you switch models, Pipal keeps an explicit level when the new model supports it and falls back to Auto otherwise. RuntimePicker.svelte index.ts

ChatGPT model access can change after sign-in. Opening Runtime in ChatGPT mode asks the host for the current choices. The host serves its saved list while it checks for changes in the background when the list is stale. A later read picks up new models and thinking levels. If a saved chat’s model disappears from the list, select an available model before sending again. App.svelte models.ts

Deep diveHow the registry validates model choices and reasoning levels

For either configured API model, startup requires the matching nonblank environment key and an ID from the pinned Pi catalog. In ChatGPT mode, an absent credential file is fine. An existing chatgpt-auth.json that Pipal cannot open, parse, or validate fails startup. models.ts credentials.ts

Pipal resolves the conversation’s saved provider/modelId against the available registry when a message arrives. A separate lookup, recordedModel(), can still retrieve catalog information such as the old model’s context window after its credential disappears. models.ts index.ts

Pi names the levels off, minimal, low, medium, high, xhigh, and max. To build the ChatGPT choices, Pipal applies the account’s advertised efforts, when present, to Pi’s model-specific mapping. For example, Pi’s off can map to OpenAI’s none. The picker uses the resulting supported list, and core rejects an explicitly requested level outside it with HTTP 400. contracts.ts models.ts index.ts

ChatGPT sign-in has two ways back

Connecting ChatGPT
  • Browser
  • Pipal
  • Pi AI
  • OpenAI
  • Disk

Same device

  1. Browser → Pipal · Start sign-in

    Continue with ChatGPT

    The dialog starts an attempt tied to your Pipal session, then polls for its status.

  2. Pipal → Pi AI · Start OAuth

    Pi prepares both ways back

    Pi opens a temporary listener on the host. It supplies an authorization link and a prompt that can receive the return link manually.

  3. Pipal → Browser · Ready

    Pipal offers the checked link

    Pipal checks the authorization endpoint, the expected return address and the presence of sign-in state. It reports the attempt as ready once Pi is also waiting for manual input.

  4. Browser → OpenAI · Approve

    Choose the account at OpenAI

    Open the authorization link in a new tab, choose the ChatGPT account and approve access. Keep the Pipal tab open.

  5. OpenAI → Browser · Redirect

    OpenAI sends the browser back to loopback

    The return address is http://127.0.0.1:1455/auth/callback.

  6. Browser → Pi AI · Deliver code

    The browser reaches Pi’s listener

    The browser is running on the Pipal host, so loopback leads to the same computer as Pi.

  7. Pi AI → OpenAI · Exchange code

    Pi exchanges the authorization code

    The code from the return link is exchanged for credentials that the host can use for model requests.

  8. Pi AI → Pipal · Credential

    Pi’s OAuth login returns a credential to Pipal

    Pipal’s login wrapper receives the credential and starts discovery before it hands the credential back to Pi to save.

  9. Pipal → OpenAI · List models

    Pipal checks what the account can use

    It requests the model list with the new access token and keeps listed models supported by the installed Pi catalog.

  10. OpenAI → Pipal · Model list

    Discovery must find an eligible model

    Pipal includes the filtered list with the credential it returns to Pi. An empty list or a failed request ends sign-in before saving the credential.

  11. Pipal → Disk · Save grant

    The credential and model list go to disk together

    Pi persists the credential through Pipal’s store. The store replaces chatgpt-auth.json with a complete file containing the device ID, credential and discovered models.

  12. Pipal → Browser · Connected

    The dialog sees the connection

    The workspace refreshes its model and profile lists when the connection status changes. Saved chats keep their model choice.

Another device

  1. Browser → Pipal · Start sign-in

    Continue with ChatGPT

    The dialog starts an attempt tied to your Pipal session, then polls for its status.

  2. Pipal → Pi AI · Start OAuth

    Pi prepares both ways back

    Pi opens a temporary listener on the host. It supplies an authorization link and a prompt that can receive the return link manually.

  3. Pipal → Browser · Ready

    Pipal offers the checked link

    Pipal checks the authorization endpoint, the expected return address and the presence of sign-in state. It reports the attempt as ready once Pi is also waiting for manual input.

  4. Browser → OpenAI · Approve

    Choose the account at OpenAI

    Open the authorization link in a new tab, choose the ChatGPT account and approve access. Keep the Pipal tab open.

  5. OpenAI → Browser · Redirect

    Loopback leads to the browser’s own device

    A browser on another device cannot reach the host listener at that address. The URL can still be copied from the address bar.

  6. Browser → Pipal · Paste URL

    Paste the whole address into Return link

    The Pipal tab checks the pasted link and posts it as callback to the attempt’s callback route.

  7. Pipal → Pi AI · Deliver URL

    Pipal answers Pi’s manual prompt

    The server checks that your session owns the waiting attempt, validates the URL against its state, and supplies the URL to Pi’s manual prompt.

  8. Pi AI → OpenAI · Exchange code

    Pi exchanges the authorization code

    The code from the return link is exchanged for credentials that the host can use for model requests.

  9. Pi AI → Pipal · Credential

    Pi’s OAuth login returns a credential to Pipal

    Pipal’s login wrapper receives the credential and starts discovery before it hands the credential back to Pi to save.

  10. Pipal → OpenAI · List models

    Pipal checks what the account can use

    It requests the model list with the new access token and keeps listed models supported by the installed Pi catalog.

  11. OpenAI → Pipal · Model list

    Discovery must find an eligible model

    Pipal includes the filtered list with the credential it returns to Pi. An empty list or a failed request ends sign-in before saving the credential.

  12. Pipal → Disk · Save grant

    The credential and model list go to disk together

    Pi persists the credential through Pipal’s store. The store replaces chatgpt-auth.json with a complete file containing the device ID, credential and discovered models.

  13. Pipal → Browser · Connected

    The dialog sees the connection

    The workspace refreshes its model and profile lists when the connection status changes. Saved chats keep their model choice.

Browser
Pipal
Pi AI
OpenAI
Disk

Browser → Pipal

Continue with ChatGPT

The dialog starts an attempt tied to your Pipal session, then polls for its status.

Switch devices to see where the same return address leads. Both paths converge before model discovery.

From the signed-in workspace, choose Settings → Account → Connect ChatGPT, then Continue with ChatGPT. When the dialog offers Continue to OpenAI, open that link and approve access in the new tab. This flow uses OAuth, a way for OpenAI to give the Pipal host credentials for model requests after you consent. Anyone signed in to this Pipal workspace can use the connected plan by selecting an available OpenAI model. The Hono server covers the token or passkey that gets you into the workspace. Settings.svelte ChatGPTLogin.svelte

OpenAI sends your browser back to 127.0.0.1:1455. Loopback leads to the computer the browser is running on. If that’s the Pipal host, Pi’s temporary listener can receive the return link there. From another device, copy the whole address after the redirect and paste it into Return link in the Pipal tab. Pipal checks the link in the browser and again on the server, then hands it to Pi to finish the exchange. ChatGPTLogin.svelte provider-login.ts

Deep diveHow the host checks, discovers, and saves the connection

providerLogin() allows one live attempt and exposes its details only to the owning session. The attempt has a 10-minute timeout and ends on cancellation, session closure, or host shutdown. Under /api/v1/providers/openai, POST /login starts the attempt and POST /login/:id/callback submits the pasted link. In OpenAI API-key mode the start and disconnect routes return HTTP 409. In ChatGPT mode sign-in requires PI_OAUTH_CALLBACK_HOST to be unset or 127.0.0.1. app.ts provider-login.ts models.ts

Pi runs the loopback listener and races it against the manual prompt. Pipal applies its own URL checks to the manual path. The pasted link must target the expected callback, carry one nonblank code and client ID, and match the attempt’s state, the value that ties the reply to this sign-in. Pipal rejects URL credentials, fragments, and provider error parameters. provider-login.ts chatgpt-callback.ts README.md

After Pi exchanges the code, Pipal requests OpenAI’s /v1/models with a 20-second timeout and redirects disabled. Discovery keeps listed models that match the pinned Pi catalog, deduplicates IDs and records compatible reasoning efforts. Sign-in requires at least one eligible model before it saves the credential. The saved list carries its own fetch time, pipalModelsFetchedAt, which token rotation preserves. models.ts credentials.ts

On a catalog or account-status read, accountCatalog() can start one background refresh when the list is at least five minutes old or has no saved timestamp. A failed refresh keeps the last good list and delays the next try for one minute. A valid refresh with zero eligible models saves an empty list. The account stays connected and a later refresh can restore choices. Signing out cancels a pending refresh so its result cannot restore the old account. models.ts chatgpt.test.ts

ChatGPTStore serializes credential changes. It writes a private temporary file, flushes it, replaces chatgpt-auth.json with a rename, and flushes the directory. The rename installs the access token, refresh token, and discovered model list together. Disconnect from Pipal removes the stored credential and retains the device ID. credentials.ts models.ts

A model and profile are now in place. When Developer sees a capability such as read, where did that capability come from, and who checks whether this chat can use it? Tools and extensions follows a call all the way to the function that runs it.

Recap

  • A profile gives Pipal defaults, instructions, and permissions. A conversation saves the settings Pi uses to answer and pins the workspace choice.
  • Saved chats refresh instructions and extension grants at the next accepted message. Applying a profile recalculates the saved turn cap.
  • ChatGPT sign-in uses the same return link on either device. Pi receives it by loopback on the host or from the checked link you paste into Pipal.
Check yourself
  1. You update Developer’s instructions and turn cap, restart Pipal, and send a message in an existing Developer chat. What does that chat pick up automatically?
    • The new instructions with the saved turn cap
    • The new turn cap with the old instructions
    • Both changes
    Answer and explanation

    The new instructions with the saved turn cap

    Admission refreshes instructions and grants, including the turn-budget extension, while using the saved cap. Reapply the profile to recalculate the cap.

  2. You connect ChatGPT while looking at a saved Local echo chat. How do you use the connected account for that chat?
    • Send again and let the chat change providers
    • Select an available OpenAI model in Runtime settings
    • Change Thinking from Auto to High
    Answer and explanation

    Select an available OpenAI model in Runtime settings

    The connection changes the available models. Your saved chat uses the model stored in its settings until you choose another.

  3. After approving access from your phone, the browser cannot reach the return address. What lets the same sign-in finish?
    • Start a second sign-in from the phone
    • Enter your workspace token in the OpenAI tab
    • Paste the full return address into the original Pipal tab
    Answer and explanation

    Paste the full return address into the original Pipal tab

    Loopback leads to the phone. Pipal’s Return link field relays the checked URL to Pi on the host.

  1. You update Developer’s instructions and turn cap, restart Pipal, and send a message in an existing Developer chat. What does that chat pick up automatically?

  2. You connect ChatGPT while looking at a saved Local echo chat. How do you use the connected account for that chat?

  3. After approving access from your phone, the browser cannot reach the return address. What lets the same sign-in finish?

In the source

Book contents

Search the book