fabro/lib/crates
Bryan Helmkamp ab68fc27d1
fix(workflow): preserve usage across session compaction (#420)
## Summary

Fixes shared-thread workflow stages that compact their session before
routing/audit bookkeeping finishes. The workflow backend now records
token usage from each `Session::process_input` call as it happens,
instead of slicing assistant turns out of the final session history
after the session may have been compacted or replaced.

## Changes

- Track per-input token usage inside `fabro-agent::Session` alongside
the existing timing data.
- Use the recorded per-input usage in the workflow LLM backend for
initial prompts, retry-after-compaction prompts, and schema repair
prompts.
- Keep the invariant panic message for inconsistent session history
explicit with `expect(...)`.
- Add a black-box workflow integration test that drives a shared-thread
audit through pre-routing compaction and asserts the audit still
succeeds.

## Verification

- `ulimit -n 4096 && cargo nextest run --workspace`
- `cargo +nightly-2026-04-14 fmt --check --all`
- `cargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D
warnings`
- `cd apps/fabro-web && bun test --isolate`
- `cd apps/fabro-web && bun run typecheck`
- `cd lib/packages/fabro-api-client && bun run typecheck`
- After rebasing onto current `origin/main`: `ulimit -n 4096 && cargo
nextest run -p fabro-workflow --test it
integration::shared_thread_compaction_before_routing_audit_succeeds`

---

[![Compound
Engineering](https://img.shields.io/badge/Compound_Engineering-6366f1)](https://github.com/EveryInc/compound-engineering-plugin)
🤖 Generated with GPT-5 via [Codex](https://openai.com/codex)
2026-05-26 21:19:53 -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 fix(workflow): preserve usage across session compaction (#420) 2026-05-26 21:19:53 -04:00
fabro-api feat(system): report runtime integration status (#416) 2026-05-26 19:27:32 -04:00
fabro-auth refactor: rationalize server secret scopes (vault-only for optional int… (#401) 2026-05-25 17:26:01 -04:00
fabro-checkpoint Make git metadata sandbox-native 2026-04-27 21:43:15 -07:00
fabro-cli Replace bare unwrap() with documented expect() across production runtim… (#415) 2026-05-26 17:46:39 -04:00
fabro-client feat: Add approve/deny run controls to MCP and CLI (#400) 2026-05-25 15:49:57 -04:00
fabro-config feat(system): report runtime integration status (#416) 2026-05-26 19:27:32 -04:00
fabro-core Replace bare unwrap() with documented expect() across production runtim… (#415) 2026-05-26 17:46:39 -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 Add provider-backed sandbox inventory API and rename SandboxProvider to… (#409) 2026-05-25 22:41:57 -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 Add provider-backed sandbox inventory API and rename SandboxProvider to… (#409) 2026-05-25 22:41:57 -04:00
fabro-interview Migrate sandbox config to named environments; add InterviewOption metad… (#372) 2026-05-23 15:47:33 -04:00
fabro-llm Replace bare unwrap() with documented expect() across production runtim… (#415) 2026-05-26 17:46:39 -04:00
fabro-macros refactor(dev): simplify generated docs tooling 2026-04-24 18:41:00 -04:00
fabro-manifest Replace run-scoped sandbox config with named environments (#360) 2026-05-23 13:03:21 -04:00
fabro-mcp Add legacy SSE MCP transport support (#386) 2026-05-24 15:29:01 -04:00
fabro-mcp-server feat: Add approve/deny run controls to MCP and CLI (#400) 2026-05-25 15:49:57 -04:00
fabro-model fix(model): retire GPT-5.2 and GPT-5.3 catalog entries (#412) 2026-05-26 00:06:50 -04:00
fabro-oauth Replace bare unwrap() with documented expect() across production runtim… (#415) 2026-05-26 17:46:39 -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 Add provider-backed sandbox inventory API and rename SandboxProvider to… (#409) 2026-05-25 22:41:57 -04:00
fabro-server fix(server): enforce content security policy (#421) 2026-05-26 21:19:36 -04:00
fabro-slack feat(system): report runtime integration status (#416) 2026-05-26 19:27:32 -04:00
fabro-spa feat(dev): gitignore embedded spa assets 2026-04-26 21:31:11 -04:00
fabro-static refactor: rationalize server secret scopes (vault-only for optional int… (#401) 2026-05-25 17:26:01 -04:00
fabro-store Add provider-backed sandbox inventory API and rename SandboxProvider to… (#409) 2026-05-25 22:41:57 -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 fix(skills): Ensure the local server can access project skills (#383) 2026-05-24 13:22:00 -04:00
fabro-tool feat: Add approve/deny run controls to MCP and CLI (#400) 2026-05-25 15:49:57 -04:00
fabro-tracker fix(github): refresh installation tokens during workflows 2026-05-06 07:15:18 -04:00
fabro-types feat(system): report runtime integration status (#416) 2026-05-26 19:27:32 -04:00
fabro-util Replace bare unwrap() with documented expect() across production runtim… (#415) 2026-05-26 17:46:39 -04:00
fabro-validate fix(graph): support dotted Fabro graph attributes (#324) 2026-05-20 09:31:08 -04:00
fabro-vault refactor: rationalize server secret scopes (vault-only for optional int… (#401) 2026-05-25 17:26:01 -04:00
fabro-workflow fix(workflow): preserve usage across session compaction (#420) 2026-05-26 21:19:53 -04:00