Kirby's interface to its generation service: one client, one seat registry
pip install kirby-ai==0.12.0 Copy PIP instructions
One client, replacing four independently written generation clients in kirby-api.
client.generate(seat="combat-pick", prompt="...") A seat is a row in the generation service, not a file this package reads (the generation service spec 2026-09-16): the generation service resolves the provider and model server-side, so the client only ever sends the seat's name. seeds/seats.dev.json (local stack, Ollama-backed) and seeds/seats.prod.json (Hetzner, cloud providers only) are the seeds for that table, applied by the service's seed_seats.py; they are not consulted at request time. The two files define the same seat names.
{ "tenant": "kirby", "seats": { "combat-pick": {"provider": "ollama", "model": "kirby-mythos:latest"}, "combat-review": {"provider": "ollama", "model": "kirby-mythos:latest"}, "campaign-prose": {"provider": "ollama", "model": "kirby:latest", "vision": true} } } generate() has no model or provider argument, and a test asserts their absence. The wire body carries seat and nothing that names a provider. Overriding a seat means adding a seat -- in the generation service, now, not here.
There are no defaults. An unnamed seat raises. A tool that silently picks a model has signed a claim on your behalf — and Kirby has the receipt: a provider pinned inside one module sent a local-model fight to a metered API for four months with nothing in the log to say so.
ModelChooser fills the seat kirby_combat.loop.Chooser leaves open: the engine renders the Phase as a Brief, this sends it, and takes back an action_id. One pass.
DeliberatingChooser adds a second — propose → review → execute or re-propose — because "on the menu" is a legality test, not a sanity test. The O.K. Corral keeps producing legal absurdities: a marshal who cannot see an enemy spending his Phase shooting a boarding house, five men with revolvers trying to level a saloon they could not dent. A reviewer holding the proposal catches those without anyone having to anticipate them as a rule.
DeliberatingChooser(client, propose_seat="combat-pick", review_seat="combat-review", rounds=1) rounds counts re-proposals: 0 is a single pass and behaves exactly like ModelChooser, so the two can be compared on one benchmark by changing one number. The reviewer never picks — it approves, or sends the proposal back with a stated objection, and only the objection travels back. A reviewer that cannot answer never vetoes: a dead network, prose instead of JSON, or an unrecognised verdict all resolve to execute, recorded in notes.
Two seats, not one, because reviewing is not the same job as proposing and must not become the same model by accident.
A model's answer can fail to reach any chooser — a dead transport, prose instead of JSON, an id off the menu — and by default every one of these quietly substitutes FirstLegalChooser and records why in .notes, so a benchmark keeps running rather than dying on one malformed reply. Pass fallback="raise" to opt out of that: ModelChooser, DeliberatingChooser and RoleCouncil all raise kirby_ai.NoChoice instead of substituting, carrying the actor, the offered action_ids, and the reason the model could not be honoured. This is for a harness that must be able to say "I don't know" rather than act on an unreviewed silent standby — a caller reading .notes after the fact is not the same as one deciding, per Phase, whether to proceed. The default (fallback=None, or any chooser instance) is unchanged.
A seat that decides from scratch every Phase has no memory: it closes to melee, then shoots, then closes again, and a reader watching the log cannot tell a change of mind from a change of circumstance. IntentChooser wraps another chooser and gives each actor a standing plan — an objective and a target, formed from what it actually chose — kept across Phases until something happens worth rethinking for: the target goes down or out of sight, the actor takes a hit worth a quarter of its current STUN, its stance changes, nothing on the menu serves the plan any more, or the commitment runs out. The commitment is measured in turns, not Phases, and how many is a property of the fighter: the role the engine classifies it as, moved by the psychological complications the player paid points for.
from kirby_ai import IntentChooser, ModelChooser seat = ModelChooser(client, seat="combat-pick") chooser = IntentChooser(seat, commitment_turns=2) The plan advises, it does not decide. The inner seat still picks; the live plan reaches that seat through the engine — Brief.render(extra_doctrine=...) puts it in the engine's own doctrine section, under the engine's heading and the engine's suppression, so doctrine=False and KIRBY_BRIEF_NO_DOCTRINE remove the plan along with everything else advisory. Nothing here splices text into a rendered page.
That advisory shape is the one deliberate difference from the kirby-api layer this was ported from, where a live plan continued without a model call at all: the intent layer picked the serving action itself. The price is one model call per Phase where the api made none while a plan held — for a fight of any length that is most of the calls, so IntentChooser today buys coherence and costs money, where the api's bought both. Restoring the saving is a follow-on (continue_without_call), not something this layer decides on its own.
IntentChooser installs itself on the inner chooser: it sets inner.doctrine_lines, chaining any source already there rather than replacing it. That is a side effect on an object the caller owns — a wrapper is built after the thing it wraps, so there is no other moment to do it — and two IntentChoosers over one seat would stack their lines. chooser.renders_intent says whether the plan is reaching the page at all.
fallback="raise" passes straight through: a harness that asked not to be guessed for still hears NoChoice.
TacticsDoctrine puts the engine's own tactic catalogue on the page as offers a seat can return. It takes a PhaseSituation and gives back ranked lines shaped " -> [ ] against "; install it with ModelChooser(..., doctrine_lines=TacticsDoctrine()) and they reach the reader through Brief.render(extra_doctrine=...), in the engine's own doctrine section, under the engine's suppression. Nothing here splices text into a rendered page.
from kirby_ai import ModelChooser, TacticsDoctrine seat = ModelChooser(client, seat="combat-pick", doctrine_lines=TacticsDoctrine()) What it calls in the engine: tactics_for (the catalogue, ranked — every tactic, its Plan and its Basis are kirby-combat's), PhaseSituation. tactical_situation and ordered_menu, and Brief.render(extra_doctrine=...) for delivery. The matching rule is TacticChooser's, step for step: steps are tried in order, an offer of the right kind at a different man does not count, and a tactic the menu cannot serve is skipped. Advice that contradicts the engine's own deterministic seat would be a contradiction on one page.
Why there is anything to add, and only that. Brief.doctrine already renders name -> kind: summary. A kind is not returnable — the seat must answer with an action_id — and sixteen of the catalogue's tactics name a target_id that never reaches the page, so with two enemies in front of you the engine's line says "close and strike" and does not say who. These lines are continuations of the engine's, directly below them under the same heading: they add the offer and the man and never restate the tactic's name, summary or rationale. Two tactics wanting one offer say it once. test_every_tactic_is_named_once_on_the_page renders the real page through Brief.render(extra_doctrine=...) and counts, and test_it_advises_what_the_engines_own_seat_would_take pins the first line to TacticChooser().choose() on the same Phase.
A tactic that raises is an engine defect and arrives as one. Nothing here catches; a caught exception would read as "no doctrine applies", forever.
EVChooser is a Chooser that prices every offer and takes the best: P(hit) x the STUN the engine's resolver gets through, averaged over every roll the dice can produce. It is kirby-api's sim_ai.py expected-value pick, ported.
from kirby_ai import EVChooser seat = EVChooser() # .picks records the number behind every decision No fallback. A Phase where nothing can be priced raises NoChoice rather than taking the first legal offer. A calculator that quietly stops calculating is worse than one that stops, because the fight goes on looking decided.
The to-hit number is the engine's. chance_to_hit asks resolve_to_hit (or resolve_mental_to_hit for a mental attack) once per 3d6 total, 3 through 18, and weights each answer by how often that total comes up. Both functions are public and pure — they read their inputs, spend no END, emit no event and touch no session — and both settle hit-or-miss independently of the dice handed in. So Combat Skill Levels, the No Range Modifier Advantage (6E1 p.346) and mental combat's range-free roll (6E1 p.105) are the engine's answers. The seat hands over the distance; what it costs is not its to say.
What it calls in the engine: resolve_to_hit / resolve_mental_to_hit, compute_defense (which also knows Armor Piercing, defense items and AVAD), compute_damage, killing_damage / normal_damage with the neutral body — the same four damage primitives kirby_combat.critique asks, for the same reason — and PhaseSituation.ordered_menu so scenery sorts last.
The probabilities are counted, not typed. chance_of_rolling(n) is P(3d6 <= n) enumerated off the die: 0.5 at 10, because half of 216 outcomes are 10 or under. That distribution is the only thing here the engine does not own. The killing ½d6 STUN multiplier is rolled through the engine the same way, once per face.
Ties and futility. Equal values keep the first offer in ordered_menu — no die is rolled to separate them — and a menu where every attack prices at zero raises NoChoice rather than returning one: critique would file every one of those picks as futile.
Narrator speaks one line in a fighter's voice over the events of a Phase — or says nothing, which is most Phases. The events are the engine's own; the policy is kirby-api's, ported.
from kirby_ai import Narrator narrator = Narrator(client, seat="combat-narrate", significance=0.5) line = narrator.narrate(events, situation) # str | None Nothing here stores anything. narrate returns the text and the harness writes it — in kirby-api, to its own combat_narration table keyed by (session_id, sequence). There is no narration event: the engine's CombatEvent union is closed and narration is not a state change.
One Narrator per fight. The throttle (one line per fighter per Turn) is state on the narrator. A harness that builds a fresh Narrator per request loses that history and every significant moment speaks again; keep one per session for the fight's life, as with IntentChooser. Also note the PASS door is ported verbatim: a reply that is literally "Pass!" is read as the character choosing silence.
The gate is pure and runs first. Each event is priced on a 0–1 dial and the Phase is silent unless something clears significance. The moments, most dramatic first: the fight ending (1.0), a man going down (0.9), a man left at death's door (0.8), a barrier destroyed (0.7), the scene turning on somebody (0.6), a man visibly badly hurt (0.6), a barrier going up (0.4). A wound is also priced as the fraction of the man it was taken from, so twelve STUN off a thug is a moment and twelve off a brick is not. None of these numbers is a rule — no page of 6E says when a man speaks — so they are policy here, and significance overrides all of them at once.
Vitals are read from VitalsChanged, which is where they now are: the engine's A7 work made the change itself an event, so a fight replayed from its log is narrated the same way as the fight that ran. Where the man stands after the blow comes from classify_health, the engine's one door, rather than from a before/after pair this package snapshotted.
One line per man per turn, kept on the narrator rather than queried back out of rows, with the api's single exception: the fight-ending line is never eaten because the winner spoke earlier in the turn.
None is a decision, never a failure. It means exactly three things: below significance, already spoke this turn, or the character chose silence (the seat's PASS). A seat that errors, or answers with nothing at all, raises — this returns no placeholder text.
combat-pick and campaign-prose are still Kirby's vocabulary — they are just rows scoped to the kirby tenant in the generation service now, not a file this package loads.
Rules and rows belong to their own layers, and nothing here reads either.
Prompts live here, which this file used to deny. The claim was that "a prompt is domain knowledge — callers hand this package finished strings", and there is no caller that can. kirby-combat forbids the word: prompt is in the banned-term list its vocabulary guard fails the build on, alongside llm and ollama, because the engine models choosing and stays neutral about what implements a choice — which is what lets a fight run with no dependencies at all. And the only callers that would hand the strings over are the scripts in this repository.
So a prompt for the combat-pick seat has nowhere else legal to be, and no consumer outside this package: the seat is only ever sent by the client here. The test is the same one that keeps the deliberation harness here rather than in a package of its own — if nothing outside kirby-ai can ever use it, it belongs to kirby-ai. A charter the code has broken since before it was written, in the one place the code has no alternative, is a charter that is wrong.
What that costs is real and worth stating: someone tuning a combat prompt is editing a transport package, and a HERO rules change can want a prompt change in a repo that knows nothing about HERO. The seat names are the seam that keeps this survivable — combat-pick, combat-review, combat-atmosphere say who a prompt is for without this package having to understand it.
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
None of the files in this release were uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.




