fabro/lib/crates
Bryan Helmkamp 8f36772af3
feat(llm): add input token counting (#359)
## Summary

Adds an optional `fabro-llm` API for counting model-visible input tokens
without creating a completion, with provider-native counting where
available and deterministic local estimates when exact counting is
unavailable or intentionally avoided.

## Details

- Adds `Client::count_input_tokens` plus `InputTokenCountPreference`
modes for provider-preferred, provider-required, and estimate-only
behavior.
- Implements provider count endpoints for Anthropic, Gemini, and OpenAI
while filtering request bodies to count-supported fields.
- Adds strict fallback semantics so local estimates do not hide bad
credentials, invalid requests, unsupported models,
context-length/content-filter failures, or other deterministic provider
errors.
- Adds a deterministic local estimator with explicit warning codes for
local estimates, media heuristics, opaque provider context, and provider
options.
- Documents privacy implications: provider-native counting sends the
provider-serialized model-visible request to the upstream count
endpoint, while `EstimateOnly` keeps counting local.

## Verification

- `cargo nextest run -p fabro-llm` - 385 passed, 10 skipped
- `cargo +nightly-2026-04-14 fmt --check --all`
- `cargo +nightly-2026-04-14 clippy -p fabro-llm --all-targets -- -D
warnings`
- `cargo build --workspace`

---

[![Compound
Engineering](https://img.shields.io/badge/Compound_Engineering-6366f1)](https://github.com/EveryInc/compound-engineering-plugin)
🤖 Generated with GPT-5 (context unknown, thinking not disclosed) via
[Codex](https://openai.com/codex)
2026-05-23 05:52:54 -04:00
..
build-support fix(build): refresh embedded git sha on branch commits 2026-05-09 14:10:04 -04:00
fabro-acp fix(workflow): capture configured artifacts once (#337) 2026-05-21 10:52:22 -04:00
fabro-agent feat(llm): add input token counting (#359) 2026-05-23 05:52:54 -04:00
fabro-api feat: add run.checkpoint.skip_git_hooks to bypass Git commit hooks (#355) 2026-05-22 17:26:06 -04:00
fabro-auth feat(workflow): enforce strict api/acp backends (#307) 2026-05-18 13:20:56 -04:00
fabro-checkpoint Make git metadata sandbox-native 2026-04-27 21:43:15 -07:00
fabro-cli fix(agent): retry retryable mid-stream LLM failures 2026-05-22 21:00:50 -04:00
fabro-client Stage-based pairing API and fabro_run_pair MCP tool (#344) 2026-05-21 21:57:55 -04:00
fabro-config feat: add run.checkpoint.skip_git_hooks to bypass Git commit hooks (#355) 2026-05-22 17:26:06 -04:00
fabro-core feat: Replace duration/elapsed fields with wall_time_ms and StageTiming (#343) 2026-05-21 21:06:40 -04:00
fabro-dev feat: add [run.agent] fabro_tools opt-in for worker run tools (#348) 2026-05-22 09:41:27 -04:00
fabro-devcontainer refactor(static): centralize env var names 2026-04-24 12:29:51 -04:00
fabro-dump feat: Replace duration/elapsed fields with wall_time_ms and StageTiming (#343) 2026-05-21 21:06:40 -04:00
fabro-github fix(github): refresh installation tokens during workflows 2026-05-06 07:15:18 -04:00
fabro-graphviz fix(graph): support dotted Fabro graph attributes (#324) 2026-05-20 09:31:08 -04:00
fabro-hooks Add event-sourced todo tools for OpenAI and Anthropic profiles (#353) 2026-05-22 13:44:42 -04:00
fabro-http refactor(static): centralize env var names 2026-04-24 12:29:51 -04:00
fabro-install refactor(install): share persistence pipeline (#332) 2026-05-21 08:04:04 -04:00
fabro-interview Stage-based pairing API and fabro_run_pair MCP tool (#344) 2026-05-21 21:57:55 -04:00
fabro-llm feat(llm): add input token counting (#359) 2026-05-23 05:52:54 -04:00
fabro-macros refactor(dev): simplify generated docs tooling 2026-04-24 18:41:00 -04:00
fabro-manifest fix(workflow): allow workflow-root template partials (#322) 2026-05-20 09:22:28 -04:00
fabro-mcp Add agent context observability events (memory, skills, MCP tools) (#356) 2026-05-22 19:06:00 -04:00
fabro-mcp-server Add fabro_run_get read-only run inspection tool (#358) 2026-05-22 19:03:56 -04:00
fabro-model Compute LLM cost on-read for in-flight billing stages (#345) 2026-05-21 19:25:00 -04:00
fabro-oauth fix(error): preserve remaining error context 2026-05-02 10:51:15 -04:00
fabro-options-metadata refactor(dev): simplify generated docs tooling 2026-04-24 18:41:00 -04:00
fabro-proc refactor(static): centralize env var names 2026-04-24 12:29:51 -04:00
fabro-redact refactor(integrations): make chat integrations Slack-only 2026-05-09 11:43:16 -04:00
fabro-sandbox feat(llm): add input token counting (#359) 2026-05-23 05:52:54 -04:00
fabro-server fix(agent): use raw sandbox reads for edits 2026-05-22 21:26:36 -04:00
fabro-slack feat(slack): render plan summary + run link in interview messages (re #253, stacked on #252) (#254) 2026-05-13 07:41:54 -04:00
fabro-spa feat(dev): gitignore embedded spa assets 2026-04-26 21:31:11 -04:00
fabro-static refactor(llm): split provider identity from adapters (#280) 2026-05-16 13:13:41 -04:00
fabro-store feat(fabro-types): promote transcript primitives and extend agent event… (#357) 2026-05-22 20:40:10 -04:00
fabro-telemetry refactor(workflow): remove retro stage (#230) 2026-05-09 10:18:20 -04:00
fabro-template feat(template): resolve template error locations (#333) 2026-05-20 20:15:04 -04:00
fabro-test feat(cli): add Fabro MCP server (#236) 2026-05-11 18:20:50 -04:00
fabro-tool Add fabro_run_get read-only run inspection tool (#358) 2026-05-22 19:03:56 -04:00
fabro-tracker fix(github): refresh installation tokens during workflows 2026-05-06 07:15:18 -04:00
fabro-types feat(fabro-types): promote transcript primitives and extend agent event… (#357) 2026-05-22 20:40:10 -04:00
fabro-util refactor(install): share persistence pipeline (#332) 2026-05-21 08:04:04 -04:00
fabro-validate fix(graph): support dotted Fabro graph attributes (#324) 2026-05-20 09:31:08 -04:00
fabro-vault refactor(auth): split credential sources and vault schemas (#306) 2026-05-18 11:07:42 -04:00
fabro-workflow fix(agent): use raw sandbox reads for edits 2026-05-22 21:26:36 -04:00