Skip to content

Default personas, usable unselected, and token usage per agent and per turn - #323

Merged
mattshax merged 1 commit into
mainfrom
default-personas-usage
Sep 7, 2026
Merged

Default personas, usable unselected, and token usage per agent and per turn#323
mattshax merged 1 commit into
mainfrom
default-personas-usage

Conversation

@mattshax

@mattshax mattshax commented Sep 7, 2026

Copy link
Copy Markdown
Member

Five personas ship with the studio for long-running fleet work: campaign_runner, watcher, reviewer, steward, reporter, each a short set of working rules under extensions-starter/agents/. seedExtensions now fills in starter files on deployments that seeded before they existed, through a ledger (.seeded.json): a starter file is copied only when absent and never seeded before, so an edited default is never overwritten and a deleted one never returns. The library gains Duplicate, which opens a copy in the editor as a new file.

The system prompt carries a live persona catalog (rebuilt on every prompt) and a rule for using one without a selection: when a request clearly falls inside one persona's description the assistant reads it and follows its rules for that request, says which one it applied, and never switches mid-request; when delegating, each agent gets the persona that fits its objective.

Token usage is counted where the data exists. streamTurn reads a usage chunk when the stream carries one (including a usage-only final chunk), the tool loop sums them (addUsage), and the total is stored on the message as tokensUsed. An agent's pw code envelope is read by usageOf for every spelling providers use; the count lives on the agent, sums on the task (sumUsage), and shows on the Tasks page row, drill-down, and card. Nothing is shown rather than zeros where the gateway reports nothing.

Five new tests; 143 server and 9 web pass.

…r agent and per turn

Five personas ship with the studio for long-running fleet work:
campaign_runner, watcher, reviewer, steward, and reporter, each a short
set of working rules. They seed into every deployment, including ones
that seeded before they existed, through a ledger that copies a starter
file only when it is absent and has never been seeded, so an edited
default is never overwritten and a deleted one never comes back. The
library gains a Duplicate action, which opens a copy in the editor.

The system prompt carries a live catalog of personas and a rule for
using one without a selection: when a request clearly falls inside one
persona's description, the assistant reads it and follows its rules for
that request, says which one it applied, and never switches
mid-request; when delegating, each agent gets the persona that fits.

Token usage is now counted where the data exists. A chat turn sums the
usage chunks its model calls report and stores the total on the message.
An agent's pw code envelope is read for every spelling providers use
(usage.prompt_tokens, input_tokens, total_cost_usd, and so on) and the
count is kept on the agent, summed on the task, and shown on the Tasks
page: on the agent row, in the drill-down, and on the task card. Where
the gateway reports nothing, nothing is shown rather than zeros.
@mattshax
mattshax merged commit b31e026 into main Sep 7, 2026
1 check passed
@mattshax
mattshax deleted the default-personas-usage branch September 7, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant