fabro/lib/crates
brynary-fabro[bot] a0fbbcfe3b
Support Anthropic fast mode (speed: fast) (#127)
This PR adds support for Anthropic's fast mode beta feature (`speed:
fast`), which enables up to 2.5x faster output for Claude Opus 4.6 at a
6x pricing premium. The implementation follows the same patterns
established by `reasoning_effort`, threading a new `speed:
Option<String>` field through the request/response pipeline from graph
stylesheet properties down through agent configuration, session
management, and the Anthropic provider adapter.

On the provider side, when `speed: "fast"` is set, the `ApiRequest`
struct now includes the `speed` field in the serialized JSON body, and
the `build_beta_header` function injects the required `anthropic-beta:
fast-mode-2026-02-01` header alongside any existing beta headers (cache,
interleaved thinking, etc.) without duplication. The response's
`usage.speed` field is parsed and propagated back through both streaming
and non-streaming paths into `StageUsage` and `Usage` types for
tracking.

Cost accounting applies a 6x multiplier in `compute_stage_cost` when
`speed == "fast"`, reflecting Anthropic's actual pricing differential.
The feature is configurable via stylesheet (`* { speed: fast; }`), which
gets wired through `SessionConfig` and prompt-mode `Request`
construction in the backend layer. New tests cover the API request
serialization, beta header injection, combined cache+fast-mode headers,
and the cost multiplier, while all existing test fixtures have been
updated with `speed: None` to maintain struct exhaustiveness.

### Fabro Details

<details>
<summary>Ran 9 stages in 58m 27s for $6.56</summary>

| Stage | Duration | Cost | Retries |
|---|---|---|---|
| start | 0s | – | 0 |
| toolchain | 0s | – | 0 |
| preflight_compile | 1m 20s | – | 0 |
| preflight_lint | 14s | – | 0 |
| implement | 47m 31s | $5.36 | 0 |
| simplify_opus | 7m 59s | $1.20 | 0 |
| simplify_gpt | 0s | – | 0 |
| verify | 25s | – | 0 |
| fmt | 1s | – | 0 |
| **Total** | **58m 27s** | **$6.56** | **0** |

</details>

<details>
<summary>Ran <code>ImplementAndSimplify.fabro</code> (12 nodes and 15
edges)</summary>

```dot
digraph ImplementAndSimplify {
    graph [
        goal="Implement and simplify",
        model_stylesheet="
            * { backend: api; model: claude-opus-4-6;}
        "
    ]
    rankdir=LR

    start [shape=Mdiamond, label="Start"]
    exit  [shape=Msquare, label="Exit"]

    toolchain         [label="Toolchain", shape=parallelogram, script="command -v cargo >/dev/null || { curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && sudo ln -sf $HOME/.cargo/bin/* /usr/local/bin/; }; cargo --version 2>&1", max_retries=0]
    preflight_compile [label="Preflight Compile", shape=parallelogram, script="cargo check -q --workspace 2>&1", max_retries=0]
    preflight_lint    [label="Preflight Lint", shape=parallelogram, script="cargo clippy -q --workspace -- -D warnings 2>&1", max_retries=0]
    fix_lints         [label="Fix Lints", prompt="The preflight lint step failed. Read the build output from context and fix all clippy lint warnings.", max_visits=3]
    implement         [label="Implement", prompt="Read the plan file referenced in the goal and implement every step. Make all the code changes described in the plan. Use red/green TDD."]
    simplify_opus     [label="Simplify (Opus)", prompt="@prompts/simplify.md"]
    simplify_gpt      [label="Simplify (GPT-54)", prompt="@prompts/simplify.md", model="gpt-54"]
    verify            [label="Verify", shape=parallelogram, script="cargo clippy -q --workspace -- -D warnings 2>&1 && cargo nextest run --cargo-quiet --workspace --status-level fail 2>&1", goal_gate=true, retry_target="fixup"]
    fixup             [label="Fixup", prompt="The verify step failed. Read the build output from context and fix all clippy lint warnings and test failures.", max_visits=3]
    fmt               [label="Format", shape=parallelogram, script="cargo fmt --all 2>&1", max_retries=0]

    start -> toolchain
    toolchain -> preflight_compile [condition="outcome=success"]
    toolchain -> exit
    preflight_compile -> preflight_lint [condition="outcome=success"]
    preflight_compile -> exit
    preflight_lint -> implement [condition="outcome=success"]
    preflight_lint -> fix_lints
    fix_lints -> preflight_lint
    implement -> simplify_opus -> simplify_gpt -> verify
    verify -> fmt   [condition="outcome=success"]
    verify -> fixup
    fixup -> verify
    fmt -> exit
}

```

</details>

⚒️ Generated with [Fabro](https://fabro.sh)

---------

Co-authored-by: Fabro <noreply@fabro.sh>
2026-03-21 14:37:42 -04:00
..
fabro-agent Support Anthropic fast mode (speed: fast) (#127) 2026-03-21 14:37:42 -04:00
fabro-api Support Anthropic fast mode (speed: fast) (#127) 2026-03-21 14:37:42 -04:00
fabro-beastie Fix fabro-beastie linker error by linking IOKit framework 2026-03-15 18:27:42 -04:00
fabro-cli Support Anthropic fast mode (speed: fast) (#127) 2026-03-21 14:37:42 -04:00
fabro-config Fix: Workflow TOML config lost in detach mode (#138) 2026-03-21 14:15:13 -04:00
fabro-db rename Arc to Fabro in all Rust crates, symbols, env vars, and supporting files 2026-03-12 12:25:58 -04:00
fabro-devcontainer Fix: Remove std::env::set_var/remove_var from tests (#101) 2026-03-19 13:09:46 -04:00
fabro-git-storage Add fabro rewind command to rewind workflow runs to earlier checkpoints 2026-03-14 11:38:17 -04:00
fabro-github Merge fabro-linear and GitHub tracker into fabro-tracker (#108) 2026-03-19 22:26:32 -04:00
fabro-graphviz Support Anthropic fast mode (speed: fast) (#127) 2026-03-21 14:37:42 -04:00
fabro-hooks Support Anthropic fast mode (speed: fast) (#127) 2026-03-21 14:37:42 -04:00
fabro-interview Decompose fabro run into create / start / attach (#116) 2026-03-20 14:08:54 -04:00
fabro-llm Support Anthropic fast mode (speed: fast) (#127) 2026-03-21 14:37:42 -04:00
fabro-mcp Move config type tests into fabro-config 2026-03-17 15:21:16 -04:00
fabro-model Update model catalog snapshots with new effort field 2026-03-21 12:11:09 -04:00
fabro-openai-oauth Add Codex endpoint support for OpenAI OAuth flow 2026-03-17 00:47:47 -04:00
fabro-retro Extract fabro-retro crate from fabro-workflows 2026-03-17 11:48:40 -04:00
fabro-sandbox Unified WorktreeSandbox (#117) 2026-03-20 15:35:04 -04:00
fabro-slack Extract fabro-interview crate from fabro-workflows 2026-03-17 13:53:36 -04:00
fabro-telemetry Fix release CI test failures caused by telemetry fork flushing stdout 2026-03-19 15:18:03 -04:00
fabro-tracker Merge fabro-linear and GitHub tracker into fabro-tracker (#108) 2026-03-19 22:26:32 -04:00
fabro-types rename Arc to Fabro in all Rust crates, symbols, env vars, and supporting files 2026-03-12 12:25:58 -04:00
fabro-util Unify goal prefix stripping into shared strip_goal_decoration() in fabro-util 2026-03-20 20:58:59 -04:00
fabro-validate Add node-level model validation + missing catalog aliases (#110) 2026-03-19 22:48:08 -04:00
fabro-workflows Support Anthropic fast mode (speed: fast) (#127) 2026-03-21 14:37:42 -04:00