Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
39 changes: 35 additions & 4 deletions .agents/skills/behaviors/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ The pages below are its documentation. Read the ones a task needs before writing
| Add behaviors to a project; hold a conversation, judge outputs, and summarize verdicts in fxtr steps; test without credentials | [Calling language models](../../../docs/behaviors/guides/language-models.mdx) |
| Pick a provider, an adapter, and an exact model ID | [Choosing models](../../../docs/behaviors/guides/choosing-models.mdx) |
| Script users or simulate them with models (a base model, steered by a pilot), offer tools, or write a custom conversation flow | [Policies and tools](../../../docs/behaviors/guides/policies-and-tools.mdx) |
| What each provider's dialect carries, adaptation losses and refusing them, structured output (`response_format`, strict tools, tool output schemas), refusals and other stops, codecs | [Dialects and adaptation](../../../docs/behaviors/guides/dialects-and-adaptation.mdx) |
| Rollout statuses and `max_turns`, failures, retries, streaming | [Rollout outcomes and retries](../../../docs/behaviors/guides/rollout-outcomes.mdx) |
| Messages and content, stored records, transcripts, conversations in the viewer, checkpoints | [Conversation records and checkpoints](../../../docs/behaviors/guides/conversation-records.mdx) |
| Run Docent readings, or convert records for Docent | [Docent readings](../../../docs/behaviors/guides/docent-readings.mdx) |
| Choose a layer; imports, adapters and their options, model providers, sampling and reasoning settings, requests and responses | [API overview](../../../docs/behaviors/reference/api.mdx) |
| Choose a layer; imports, adapters (including Gemini and OpenRouter) and their options, model providers, sampling, reasoning and speed settings, requests and responses | [API overview](../../../docs/behaviors/reference/api.mdx) |
| Steps, workflows, arrays, launching jobs, and the step cache | the adjacent [fxtr skill](../fxtr/SKILL.md) |

## Best practices
Expand All @@ -33,6 +34,36 @@ The pages below are its documentation. Read the ones a task needs before writing
models shows, rather than substituting another. Without credentials to check, take candidate
IDs from the provider's published catalog, and tell the user that account access has not been
verified.
- **Shape model experiments as the guide does**: one step per conversation, with every setting
that affects the request in a configuration entity; fxtr replicas for repeated samples; and
separate steps for judging and for aggregating verdicts.
- **Make each argument of a model call its own step input.** Then every result points at the
exact settings that produced it, and the cache sees every setting. Hard-code nothing that
affects a request in a step.
- The model is a `model_name` string, such as `openai/gpt-6-luna`. The project's own
`make_api(model_name)` builds the `ModelAPI` from it, and the step closes the API in
`finally`. The string is the record of which model was called: a `Judgment` holds none.
- Sampling is a `SamplingParamsEntity` the project defines, a frozen `DataclassEntity` with one
field, `params: SamplingParams`. An fxtr array can't hold a `SamplingParams` as a value, but
it can hold a reference to an entity. behaviors provides no such type.
- A prompt, a rubric, the judge's instructions, and an output schema (as JSON text) are
`TextEntity` inputs.
- **Shape model experiments as the guide does**: one step per conversation; fxtr replicas for
repeated samples; and separate steps for transcripts, judging, and aggregating judgments.
- **Judge with behaviors' `judge`**, from `behaviors.judging.judge`, which returns a `Judgment`.
Write its output schema with a `behaviors.judging.schemas` function (`binary_schema`,
`continuous_schema`, `categorical_schema`, `structured_schema`). Each starts with a
`discussion`, so the judge explains before it decides. For the instructions, start from
`DEFAULT_SYSTEM_INSTRUCTIONS_ENTITY`, from `behaviors.judging.defaults`. `judge` needs
`jsonschema`, which a project adds itself: `uv add "behaviors[models]" jsonschema`.
- **Point at evidence with a citation, not a number.** When a judge's answer has to name a place
in an entity (the message where a behavior first appears, the line a score rests on), make that
field a citation field, written by a `CustomFormat`'s `schema` method, and ask for exactly one
citation, or an empty string when there is none. The viewer draws such a field as a link that opens the entity at that place. An integer
index is drawn as a bare number.
- **Link a judge's call output first.** When you link the user to one call of a judge step, add
`section_order=output_first` to its `invocation` view, so the judgment shows above the
transcript and rubric it was given:
`p=invocation(/judge,item=0127,judge=sonnet,section_order=output_first)`.
- **Use as many citation fields as the answer needs.** One schema can have several, and they need
not be checked the same way: each way is a `CustomFormat` with a name of its own, which writes
its field with `schema(description=...)` and is passed to `judge` in `custom_formats` (lines in
a discussion, a whole message in a field that points at one). See
[Citations](../../../docs/behaviors/reference/api.mdx#citations).
58 changes: 37 additions & 21 deletions .agents/skills/first-experiment/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,27 @@ that fits: one question, answered with model calls.
4. **What are we measuring?** To make a quantitative comparison between the variables we are studying,
we need some way to measure differences in behavior. In some cases, this can just be a pure function
(e.g. response length or accuracy), but usually this will involve running a judge or grader model with
a rubric that returns a verdict. Judge models should be asked for a rationale or explanation before
giving a final answer, which should be either a numeric score or a set of named categories. XML
format for structured outputs is a good default. Note that for some exploratory tasks (like seeing
a rubric that returns a verdict. Judge with behaviors' `judge`, and give it an output schema from
`behaviors.judging.schemas`: `continuous_schema` for a numeric score, `categorical_schema` for
named categories, or `binary_schema` for yes or no. Every schema starts with a `discussion`, so
the judge explains its reasoning before it gives its answer. Note that for some exploratory tasks (like seeing
how models respond to an open-ended prompt), it might make sense to
first generate some initial data and then look at it manually before proposing what the actual
rubric or set of outcomes should be!
5. **What data types will we use to represent the experiment?** It usually makes sense to define some
new entity types to hold the results of various parts of your experiment. For some parts of the experiment, you might be able to use the types from the `behaviors` library; in this case you should
just use these. However, other things such as experiment configuration, judge results, and the final
report object should usually be experiment-specific types. By default you should use
"local.{projectname}.{TypeName}" for experiment-specific types (since there is not yet a global
registry of types).
5. **What inputs and data types will the experiment use?** Give each setting of a model call its
own workflow input, so every result points at the exact settings that produced it, and the cache
sees a changed setting:
- a model is a name with its provider, such as `anthropic/claude-opus-5-5`, which the project's
`make_api` turns into a model API;
- a prompt template is a string, and a rubric, the judge's instructions and the judge's output
schema are `TextEntity` entities;
- sampling settings go in a small entity of the project's own, `SamplingParamsEntity`, because an
array can't hold a `SamplingParams` itself.

Use behaviors' types for what they cover: `ChatRollout` for a conversation, `Transcript` for what
a judge reads, and `Judgment` for a judge's answer. Define experiment-specific types for the
sampling entity, a per-condition summary, and the final report. By default, name them
"local.{projectname}.{TypeName}" (there is not yet a global registry of types).

Show the design in one short block before writing code, along with
what each part becomes in fxtr. For example:
Expand All @@ -149,15 +158,22 @@ Summary: per model, the mean score
Size: pilot 2 x 3 x 1 = 6 conversations (6 model calls) + 6 judge calls
full 2 x 10 x 3 = 60 conversations (60 model calls) + 60 judge calls

New entity types to define:
- GenerationConfig: provider, model_name, sampling, prompt_template
- JudgeConfig: provider, model_name, sampling, rubric
- JokeGrade: topic, joke, score, rationale, judge_reply
- JokeReport: references to the jokes, grades, and summary arrays
Inputs:
- model_name, over [model]: anthropic/claude-haiku-4-5-20251001, anthropic/claude-sonnet-5-5
- sampling: one SamplingParamsEntity (max_tokens 1000), shared by the jokes and the judge
- prompt_template, topics, samples
- judge_model_name (anthropic/claude-opus-5-5), judge_sampling, judge_instructions, rubric,
output_schema (a continuous_schema from 1 to 10)

Types to define:
- SamplingParamsEntity: params
- ModelSummary: jokes, graded, mean_score
- JokeReport: references to the jokes, judgments, and summary arrays

Structure of the experiment workflow:
- a joke step mapped over [model, topic] replicated over [sample], returning a ChatRollout
- a judge step mapped over [model, topic, sample]
- a transcript step mapped over [model, topic, sample], returning a Transcript
- a judge step mapped over [model, topic, sample], calling `judge` and returning a Judgment
- a summary step mapped over [model]
```

Expand Down Expand Up @@ -197,13 +213,13 @@ and [Calling language models](../../../docs/behaviors/guides/language-models.mdx

Then tell the user what you are about to do, and then write the following:

- **One module** for the experiment, registered in `[tool.fxtr] modules`, holding its
configuration entities, its verdict and report entities, its steps, and its workflow, shaped as
the behaviors skill's best practices say. Pass each step only the fields it uses: a
- **One module** for the experiment, registered in `[tool.fxtr] modules`, holding its sampling
entity, its summary and report types, its `make_api`, its steps, and its workflow, shaped as the
behaviors skill's best practices say. Pass each step only the fields it uses: a
conversation step that receives the question's text but not its reference answer doesn't rerun
when a reference answer is corrected, and only the judge does.
- **A launcher** at the project root that builds the items, stores a configuration per condition,
runs the workflow, and prints the summary from the report in an `on_result` callback
- **A launcher** at the project root that builds the items, stores the sampling settings and the
judge's instructions, rubric and output schema, runs the workflow, and prints the summary from the report in an `on_result` callback
([Read results](../../../docs/fxtr/guides/running-and-viewing-jobs.mdx#read-results)), so its
output ends with the answer rather than the report's ID. Define the pilot and full sizes side
by side and choose one with an argument (`uv run python launch.py pilot`), so the full run is
Expand Down Expand Up @@ -284,7 +300,7 @@ changes on a first experiment:
- **Adding a new step at the end** (e.g. for a new analysis): all previous steps will hit the cache,
so you can just insert the new step into the workflow in place.
- **Changing a step's code** (how answers are parsed or scored): the cache won't notice. Clear
that step's entries, or add a configuration field, as
that step's entries, or add an input that changes with the logic, as
[Handling changes to step logic](../../../docs/fxtr/concepts/managing-the-step-cache.mdx#handling-changes-to-step-logic)
says, and tell the user which results that recomputes.

Expand Down
26 changes: 26 additions & 0 deletions .agents/skills/fxtr/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Running and viewing jobs before the first launch.
| --- | --- |
| Launch a job, watch it in the viewer, return a report and read results, resume, inspect, or share jobs | [Running and viewing jobs](../../../docs/fxtr/guides/running-and-viewing-jobs.mdx) |
| Choose how many steps run at once, or speed up a job whose steps call APIs | [Choose how many steps run at once](../../../docs/fxtr/guides/running-and-viewing-jobs.mdx#choose-how-many-steps-run-at-once) |
| Set up a remote, push a job to a fxtr hub or an OCI registry, or pull one | [Pushing and pulling jobs](../../../docs/fxtr/guides/pushing-and-pulling-jobs.mdx) |
| Reuse or recompute cached results, resolve cache conflicts, change a step's logic | [Managing the step cache](../../../docs/fxtr/concepts/managing-the-step-cache.mdx) |
| Look up a command's options | [CLI reference](../../../docs/fxtr/reference/cli.mdx) |

Expand Down Expand Up @@ -131,6 +132,31 @@ before [adding one](../../../docs/fxtr/reference/renderers.mdx#adding-a-package-
- **Keep the viewer running** across launches and renderer edits. It rebuilds the renderers when
their sources change, and the open viewer switches to them in place, so never ask the user to
reload or restart it.
- **Link the user to what you are pointing at.** The viewer's URL holds the job, the level shown,
the slice, and the open panels, so instead of describing where to click, give the user a link:
the viewer's URL (the one `fxtr view` printed, also saved in `.fxtr/viewer.json` within the project), then `#` and `&`-separated parts.

```
http://127.0.0.1:8000/#job=<job id>&w=flowchart(/outer,model=sonnet)&slice=(prompt=3)&card=judge&p=table(/outer/judge,model=sonnet)&p=.output.transcript
```

`job` is the job's ID (left out, the newest job). `w` is the workflow invocation shown (left
out, the root's trace): `trace`, `flowchart`, or the id of an `InvocationPanel` renderer
of that workflow, applied to its step path from the root, with the keys of the mapped workflows
on the way. `slice` picks dim values for every card and panel. `card` names a step of that workflow (or
`return`, what it returned) whose card to scroll to. Each `p` opens a panel, in order,
each following the one before it; `pin` opens one that stays as it is. A panel is an address,
a view applied to a location and params: the view is `table`, `invocation`, `tree`, `code`, a
renderer's or page's id, or nothing for the default; the location is a step path from the root
(`/outer/judge`), or `cid:<cid>` for an entity, then a field path (`.output.transcript`,
`.inputs.prompt`, `[2]` for a list item); params bind dims and the params a view declares, by
name, as bare values (`3`, `sonnet`) or JSON (`"two words"`, `{"message":2}`). The `invocation`
view shows one call: its status line, then its inputs, a workflow's runs, and its output; with
`section_order=output_first` the output comes right under the status line instead
(`section_order=inputs_first` is the default). Link output first when the user wants to read
what the call returned. After the first
panel, a location may be relative to the panel before it: `.field…` below it, `../step` a
sibling. Percent-encode only spaces, `%`, `&`, `#`, `+`, and quotes.

### Reading the documentation

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ jobs:
git config --global user.name "CI"
git config --global user.email "ci@example.com"
- run: uv sync ${{ matrix.sync }} --all-packages --all-extras
# Resolution rewrites uv.lock. Keep the installed minimum versions, but restore the
# committed lockfile so schema-table tests can identify the versions their snapshots pin.
- if: matrix.resolution == 'lowest-direct'
run: git restore uv.lock
# --no-sync keeps the environment just synced; a plain `uv run` would relock to the newest.
- run: uv run --no-sync pytest -n auto

Expand Down
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,15 @@ repos:
language: system
files: ^(example_projects/behavior_rollouts/.*\.py|example_projects/behavior_rollouts/pyproject\.toml|example_projects/example_project_testing\.py|pyright-base\.json)$
pass_filenames: false
- id: uv-lock-joke-eval
name: uv-lock (example_projects/joke_eval)
entry: uv lock --check --project example_projects/joke_eval
language: system
files: ^((fxtr|behaviors)/pyproject\.toml|example_projects/joke_eval/(pyproject\.toml|uv\.lock))$
pass_filenames: false
- id: pyright-joke-eval
name: pyright (example_projects/joke_eval)
entry: uv run --directory example_projects/joke_eval --frozen --group dev pyright
language: system
files: ^(example_projects/joke_eval/.*\.py|example_projects/joke_eval/pyproject\.toml|example_projects/example_project_testing\.py|pyright-base\.json)$
pass_filenames: false
11 changes: 11 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,15 @@ that someone _new_ would want to use to understand the _current_ state of the co

Default to using `anyio`'s APIs for async instead of `asyncio`.

Write docstrings in Google style. Give an `Args:` section whenever an argument is even slightly
ambiguous, and `Raises:` and `Returns:` sections where they help. Write docstrings in ASD-STE100
Simplified Technical English: short sentences, one statement in each sentence, the active voice,
and plain words. For example, write "If the column is null in the database, this function sets
it", not "a null column here is an update, made here".

Default to using `uv run pytest -n auto` to run tests in parallel when running the full test suite.

Alembic revisions: write a `downgrade()` that undoes the
revision wherever that is possible, and test the round trip; where it is not possible, the
`downgrade()` raises and says why. Each revision also leaves the tables usable by the previous
release; the rules are in `fxtr/src/fxtr/runner/postgres/migrations/__init__.py`.
Loading
Loading