fabro/lib/crates/fabro-agent/src
fabro-sh-0530[bot] 7d655d7c95
feat: expose effective agent tool list via StageProjection.agent_tools (#388)
## Summary

Adds `StageProjection.agent_tools` — a replay-authoritative list of
every tool the model can actually call — so UI and API consumers no
longer have to infer tool availability from `permission_level`. The
field is populated by a new `agent.tools.available` durable event
emitted once per stage session after provider-profile setup, MCP
integration, and access-policy filtering are complete.

### Plan Summary

- **Types (`fabro-types`)** — new `AgentToolSummary`, `AgentToolSource`,
`AgentToolCategory`, `AgentToolsAvailableProps`, and
`EventBody::AgentToolsAvailable`; `agent_tools: Vec<AgentToolSummary>`
added to `StageProjection` with skip-serializing-if-empty semantics.
- **Tool registry (`fabro-agent`)** — `ToolSource::Mcp` gains
`original_name` (no more re-parsing the qualified name downstream);
`ToolDefinitionWithSource::to_agent_tool_summary()` maps to the public
DTO; `Session::effective_tools()` / `agent_tool_summaries()` expose the
filtered list; `tool_category` split into `tool_category` (CLI gate,
defaults `Shell`) and `known_tool_category` (projection, returns `None`
→ `Other` for unknown tools).
- **Projection reducer (`fabro-store`)** — `AgentToolsAvailable`
replaces the stage's `agent_tools`; `AgentToolStarted` flips `invoked =
true` on the matching entry; legacy runs without the event get an empty
list.
- **OpenAPI + generated clients** — `AgentToolSummary`,
`AgentToolSource`, `AgentToolCategory`, `AgentToolsAvailableProps`
schemas added; `StageProjection.agent_tools` field added; `build.rs`
replacements wire them to the `fabro-types` structs.
- **Web sidebar** — new collapsible "Tools" section renders name,
description, source/category badge, and used/available state from
`stage.agent_tools`; `permission_level` is kept as secondary fallback
metadata for legacy stages.

## Key design decisions

- **`agent_tools`, not `tools`** — avoids ambiguity with MCP nested
tools and completion API tool definitions.
- **Dedicated `agent.tools.available` event** — cleaner than overloading
`agent.session.activated`; replacement semantics on replay mean
re-emission works if tool registration ever becomes mutable.
- **`original_name` carried in `ToolSource::Mcp`** — stored by the MCP
integration at registration time so the projection never needs to
re-parse qualified names like `mcp__filesystem__read_file`.
- **`invoked` is projected state, not event state** — the availability
event always emits `false`; replay of `agent.tool.started` flips
matching entries.
- **Parameter schemas omitted** — `AgentToolSummary` carries only
`name`, `description`, `source`, `category`, and `invoked` to keep
payloads small and avoid exposing implementation detail.
- **`AgentToolCategory::Other` for unknown tools** — unlike the CLI
permission gate (which defaults to `Shell` to require approval), the
projection uses `Other` to surface unrecognized MCP/skill tools
accurately.


### Fabro Details

<details>
<summary>Ran 8 stages in 56m 37s for $58.75</summary>

| Stage | Duration | Cost | Retries |
|---|---|---|---|
| start | 0s | – | 0 |
| toolchain | 1s | – | 0 |
| preflight_compile | 2m 0s | – | 0 |
| preflight_lint | 2m 15s | – | 0 |
| implement | 22m 54s | $42.64 | 0 |
| simplify_opus | 16m 41s | $10.62 | 0 |
| simplify_gpt | 3m 43s | $5.49 | 0 |
| verify | 8m 33s | – | 0 |
| **Total** | **56m 37s** | **$58.75** | **0** |

</details>

<details>
<summary>Ran <code>ImplementPlan.fabro</code> (11 nodes and 14
edges)</summary>

```dot
digraph ImplementPlan {
    graph [
        goal="Implement and simplify",
        model_stylesheet="
            * { model: claude-opus-4-7; }
        "
    ]
    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 +nightly-2026-04-14 clippy -q --workspace --all-targets -- -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.", model="gpt-55", reasoning_effort="xhigh"]
    simplify_opus     [label="Simplify (Opus)", prompt="@prompts/simplify.md"]
    simplify_gpt      [label="Simplify (GPT-55)", prompt="@prompts/simplify.md", model="gpt-55"]
    verify            [label="Verify", shape=parallelogram, script="git fetch origin main 2>&1 && git merge --no-edit --no-stat origin/main 2>&1 && cargo +nightly-2026-04-14 fmt --all 2>&1 && cargo dev docs refresh 2>&1 && cargo +nightly-2026-04-14 fmt --check --all 2>&1 && { command -v rg >/dev/null 2>&1 || { echo 'rg is required for verify'; exit 127; }; } && ! rg -n 'AuthMode::Disabled|RunAuthMethod|RunSubjectProvenance|\bActorRef\b|\bActorKind\b|AuthenticatedSubject|AuthenticatedService|AuthorizeRunScoped|AuthorizeRunBlob|AuthorizeStageArtifact|AuthorizeCommandLog|auth_method\s*==\s*\"disabled\"' lib/crates apps lib/packages docs/public/api-reference/fabro-api.yaml 2>&1 && cargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D warnings 2>&1 && cargo nextest run --workspace --status-level slow --profile ci 2>&1 && cargo dev docs check 2>&1 && bun install --frozen-lockfile 2>&1 && (cd apps/fabro-web && bun run typecheck) 2>&1 && (cd apps/fabro-web && bun run test) 2>&1 && (cd lib/packages/fabro-api-client && bun run typecheck) 2>&1 && cargo dev build -- -p fabro-cli --release 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 format, clippy, Rust test, docs, TypeScript typecheck/test, and build failures.", max_visits=3]

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

```

</details>

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

---------

Co-authored-by: Fabro <noreply@fabro.sh>
Co-authored-by: Bryan Helmkamp <bryan@brynary.com>
2026-05-24 16:41:55 -04:00
..
profiles feat(agent): add Anthropic TaskGet and task reminders 2026-05-22 22:10:46 -04:00
agent_profile.rs refactor(llm): split provider identity from adapters (#280) 2026-05-16 13:13:41 -04:00
apply_patch.lark feat(agent): make OpenAI apply_patch Codex-compatible (#350) 2026-05-22 10:30:18 -04:00
apply_patch.rs Add context-window snapshot API for agent stages (#378) 2026-05-23 19:58:18 -04:00
cli.rs feat: expose effective agent tool list via StageProjection.agent_tools (#388) 2026-05-24 16:41:55 -04:00
compaction.rs agent: use API usage baseline for compaction context estimate (#366) 2026-05-23 12:55:23 -04:00
config.rs Expose PermissionLevel on StageProjection and add sortable run columns (#373) 2026-05-23 19:41:01 -04:00
context_window.rs feat: expose effective agent tool list via StageProjection.agent_tools (#388) 2026-05-24 16:41:55 -04:00
docker_sandbox.rs Rename SessionConfig to SessionOptions and McpServerConfig to McpServerSettings 2026-04-02 06:47:42 -07:00
error.rs fmt: apply nightly rustfmt after merge 2026-04-11 13:43:30 -04:00
event.rs Add event-sourced todo tools for OpenAI and Anthropic profiles (#353) 2026-05-22 13:44:42 -04:00
file_tracker.rs feat(agent): make OpenAI apply_patch Codex-compatible (#350) 2026-05-22 10:30:18 -04:00
history.rs agent: use API usage baseline for compaction context estimate (#366) 2026-05-23 12:55:23 -04:00
lib.rs Add context-window snapshot API for agent stages (#378) 2026-05-23 19:58:18 -04:00
local_sandbox.rs Create fabro-sandbox crate, consolidating Sandbox trait and all implementations 2026-03-19 20:06:19 -04:00
loop_detection.rs feat(session): add server-backed agent sessions (#278) 2026-05-16 17:25:05 -04:00
mcp_integration.rs feat: expose effective agent tool list via StageProjection.agent_tools (#388) 2026-05-24 16:41:55 -04:00
memory.rs refactor(agent): simplify reviewed changes 2026-05-22 21:51:45 -04:00
question_tools.rs Add context-window snapshot API for agent stages (#378) 2026-05-23 19:58:18 -04:00
read_before_write_sandbox.rs Create fabro-sandbox crate, consolidating Sandbox trait and all implementations 2026-03-19 20:06:19 -04:00
sandbox.rs Add ACP backend support (#237) 2026-05-11 23:39:43 -04:00
session.rs feat: expose effective agent tool list via StageProjection.agent_tools (#388) 2026-05-24 16:41:55 -04:00
skills.rs Add context-window snapshot API for agent stages (#378) 2026-05-23 19:58:18 -04:00
subagent.rs Add context-window snapshot API for agent stages (#378) 2026-05-23 19:58:18 -04:00
task_reminder.rs feat(agent): add Anthropic TaskGet and task reminders 2026-05-22 22:10:46 -04:00
test_support.rs Add context-window snapshot API for agent stages (#378) 2026-05-23 19:58:18 -04:00
todo_runtime.rs Add event-sourced todo tools for OpenAI and Anthropic profiles (#353) 2026-05-22 13:44:42 -04:00
todo_tools.rs Add context-window snapshot API for agent stages (#378) 2026-05-23 19:58:18 -04:00
tool_execution.rs Add context-window snapshot API for agent stages (#378) 2026-05-23 19:58:18 -04:00
tool_permissions.rs feat: expose effective agent tool list via StageProjection.agent_tools (#388) 2026-05-24 16:41:55 -04:00
tool_registry.rs feat: expose effective agent tool list via StageProjection.agent_tools (#388) 2026-05-24 16:41:55 -04:00
tools.rs Add context-window snapshot API for agent stages (#378) 2026-05-23 19:58:18 -04:00
truncation.rs refactor: unify metadata snapshot failure helpers and drop floor_char_boundary copies 2026-05-01 09:17:47 -04:00
types.rs Fold context-window data into agent.message, remove snapshot event (#390) 2026-05-24 15:48:21 -04:00