Skip to content
UFFeSciencePublic

About

ANCHOR is a framework for capturing the provenance of multi-agent workflows using an interaction-centric approach.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

12 Commits

Folders and files

Repository files navigation

Anchor logo


ANalysis of agentiC workflows via HistOry and pRovenance

Overview

Anchor is a framework for capturing and analyzing provenance in agentic workflows using an interaction-centric model.

The project focuses on representing how agents, tools, users, model calls, delegations, and intentions interact over time. This makes agentic workflows easier to trace, reproduce, audit, and study.

Repository Layout

src/anchor/
  model/                Interaction-centric provenance model
  observability/        BeeAI/OpenInference instrumentation helpers
  telemetry/            Span collection, translation, schema, and persistence
  prov/                 PROV document and graph generation
  sailor/               SQLite provenance reuse queries and agent adapters

examples/
  beeai/phylogenetic_subtrees/      BeeAI-specific bioinformatics case study
  beeai/synthetic_tool_selection/   BeeAI consumer for Sailor validation
  commons/phylogenetic_subtrees/    Shared MCP tools and data for the case study
  commons/synthetic_tool_selection/ Shared synthetic MCP tools and simulator

docs/                   Architecture and provenance model notes
assets/                 Images and diagrams
tests/                  Test suite placeholder

Default model: Groq

All BeeAI examples and Sailor default to groq:openai/gpt-oss-120b, using GROQ_API_KEY through BeeAI's native Groq adapter. No additional provider package is required beyond the BeeAI dependencies. Groq does not use OPENAI_API_KEY or OPENAI_API_BASE, so existing Hugging Face settings can remain configured.

With GROQ_API_KEY already exported, run from the repository root:

export ANCHOR_LLM=groq:openai/gpt-oss-120b
export ANCHOR_SAILOR_LLM=groq:openai/gpt-oss-120b
uv run --extra beeai python -m examples.beeai.synthetic_phylogenetic_subtrees.main

These exports override model selections left in an existing .env. If no model is configured, Groq is selected automatically. ANCHOR_SAILOR_LLM is optional; when unset, Sailor follows ANCHOR_LLM.

Other providers remain available: set ANCHOR_LLM=ollama:granite3.3:8b for Ollama, or ANCHOR_LLM=openai:openai/gpt-oss-20b with the Hugging Face router's OPENAI_API_KEY and OPENAI_API_BASE. Set or unset ANCHOR_SAILOR_LLM accordingly. The Ollama setup below is only needed when choosing that provider; MAFFT is still required by the phylogenetic workflows.

Install

Anchor uses pyproject.toml and can be installed with uv.

Start from the repository root:

cd anchor

Install uv and the external system dependencies used by the BeeAI phylogenetic subtrees example:

brew install uv
brew install mafft
brew install ollama

Then create a local Python environment and install Anchor with the BeeAI example dependencies:

export UV_PROJECT_ENVIRONMENT=venv
uv venv --python 3.12 venv
source venv/bin/activate
uv sync --extra beeai

Anchor uses a src/ package layout. Use a non-hidden virtual environment directory such as venv, not .venv, because some Python/uv combinations skip .pth files inside hidden environment paths. If that happens, imports such as import anchor will fail even though the project is installed.

If uv sync --extra beeai does not install the editable project in your local setup, use:

uv pip install -e ".[beeai]"

BeeAI Case Study

The BeeAI phylogenetic subtrees workflow is intentionally kept as an example, not as part of Anchor's core package. It demonstrates how Anchor can instrument a multi-agent workflow that validates FASTA files, runs multiple sequence alignment, builds phylogenetic trees, and identifies frequent subtrees.

1. Configure Environment Variables

cp .env.example .env

The default .env points to the bundled sample data:

INPUT_PATH=examples/commons/phylogenetic_subtrees/data/input/testset
OUTPUT_PATH=examples/commons/phylogenetic_subtrees/data/output
ANCHOR_OUTPUT_PATH=.anchor
ANCHOR_DB_PATH=.anchor/workflow_db.sqlite

ANCHOR_OUTPUT_PATH controls where Anchor writes its own provenance outputs. The default is .anchor.

Provenance Explorer

Anchor includes a small read-only visual explorer for the default SQLite provenance database. It shows the workflow model as an interactive graph and lets you inspect workflow, participant, task, interaction, and intention nodes. Run it with the optional UI dependencies:

uv sync --extra ui --no-editable --reinstall-package anchor-agentic-provenance
PYTHONPATH=src uv run --no-sync python -m anchor.visualization.app

Then open http://127.0.0.1:8765. The explorer never writes to the database. The first version is intended for completed workflow executions; live trace updates will require incremental persistence in the collector. If the workflow was run under an experiment directory, pass that database explicitly, for example .anchor/experiments/hf_smoke/workflow_db.sqlite.

On macOS, if uv run reports No module named 'anchor', the Python runtime is usually skipping the editable .pth file inside the hidden .venv directory. The PYTHONPATH=src prefix above makes the checkout importable immediately. Alternatively, recreate the environment in a non-hidden directory such as venv and run UV_PROJECT_ENVIRONMENT=venv uv sync --extra ui.

Anchor uses the canonical participant-oriented SQLite schema and writes directly to .anchor/workflow_db.sqlite by default. Set ANCHOR_DB_PATH to choose another database path.

2. Configure Ollama (optional alternative)

The BeeAI example currently uses the model configured in:

examples/beeai/phylogenetic_subtrees/constants.py

To select Ollama instead of the Groq default:

export ANCHOR_LLM=ollama:granite3.3:8b

Start Ollama in one terminal:

ollama serve

In another terminal, pull the model:

ollama pull granite3.3:8b

3. Run The Example

From the repository root:

uv run python -m examples.beeai.phylogenetic_subtrees.main

You can also use the example runner:

uv run ./examples/beeai/phylogenetic_subtrees/run.sh

The runner removes previous example outputs and then starts the workflow.

4. Expected Outputs

After a successful run, Anchor and the example should create:

.anchor/workflow_db.sqlite
examples/commons/complex_phylogenetic_subtree/data/output/validated-files/
examples/commons/complex_phylogenetic_subtree/data/output/align/
examples/commons/complex_phylogenetic_subtree/data/output/frequent-subtrees.json

The current multi-tool MCP server writes the alignment and subtree artifacts under examples/commons/complex_phylogenetic_subtree/data/output/; the runner clears both locations before a run.

Anchor stores captured workflow data under .anchor/workflow_db.sqlite by default.

If you change ANCHOR_OUTPUT_PATH, replace .anchor in the paths above with your configured directory.

Persistence

Anchor persists the participant-oriented provenance model directly in SQLite. The schema includes participants, capabilities, interactions, tasks, task_executions, relations, attributes, and workflow execution telemetry. Records with the same provenance identifier are upserted, so repeated workflow executions can share one database.

The default database is:

.anchor/workflow_db.sqlite

Set ANCHOR_DB_PATH to use a different file. To inspect the database visually, you can install DB Browser for SQLite:

brew install db-browser-for-sqlite

The current schema is intentionally not migrated in place. If an existing database was created by the removed legacy collector, point ANCHOR_DB_PATH to a new file (or remove that generated database) before running a workflow.

Reuse Provenance With Sailor

Sailor is Anchor's provenance reuse layer. It reads Anchor's canonical SQLite database and summarizes historical tool behavior so humans or workflow agents can make better execution choices.

By default, Sailor reads:

${ANCHOR_OUTPUT_PATH:-.anchor}/workflow_db.sqlite

Sailor ignores internal framework tools by default, including BeeAI's think, final_answer, HandoffTool targets, agent calls, and Sailor's own query tools, so recommendations focus on domain tools. To add more ignored tool names:

export ANCHOR_SAILOR_IGNORED_TOOLS=debug_tool,internal_router

To ignore additional provenance target participant types:

export ANCHOR_SAILOR_IGNORED_PARTICIPANT_TYPES=agent,router

Run direct provenance queries from Python:

uv run python -c "from anchor.sailor import compare_tools; print(compare_tools())"
uv run python -c "from anchor.sailor import get_execution_recommendations; print(get_execution_recommendations())"

Sailor recommendation policy can be configured with:

export ANCHOR_SAILOR_POLICY=reliability
export ANCHOR_SAILOR_POLICY=speed
export ANCHOR_SAILOR_POLICY=speed_reliability
export ANCHOR_SAILOR_MAX_FAILURE_RATE=0.2

Useful query functions:

from anchor.sailor import (
    compare_tools,
    get_execution_recommendations,
    get_tool_failures,
    get_tool_performance,
)

The BeeAI phylogenetic subtrees example can enable a Sailor provenance agent with ANCHOR_SAILOR_ENABLED=true. When enabled, each specialist receives a provenance_agent handoff and can consult historical tool performance before choosing among equivalent domain tools. If no SQLite history exists, Sailor reports that clearly and avoids inventing recommendations.

Synthetic Tool Selection Example

The synthetic tool-selection workflow is a smaller BeeAI + MCP example designed to validate Sailor. It has one workflow with three ordered stages:

cleaning -> feature extraction -> scoring

Each stage has multiple tools with the same purpose but different simulated success rates and runtimes. The simulator is probabilistic and reproducible with SYNTHETIC_SEED.

Run it several times to create provenance history:

export SYNTHETIC_SEED=42
export SYNTHETIC_TIME_SCALE=1.0
uv run python -m examples.beeai.synthetic_tool_selection.main

Then ask Sailor to compare equivalent tools:

uv run python -c "from anchor.sailor import compare_tools; print(compare_tools(tool_names=['fast_cleaner', 'balanced_cleaner', 'strict_cleaner']))"
uv run python -c "from anchor.sailor import compare_tools; print(compare_tools(tool_names=['quick_feature_extractor', 'robust_feature_extractor', 'experimental_feature_extractor']))"
uv run python -c "from anchor.sailor import compare_tools; print(compare_tools(tool_names=['fast_scorer', 'accurate_scorer', 'unstable_scorer']))"

Use OUTPUT_PATH to redirect synthetic workflow outputs and ANCHOR_OUTPUT_PATH to redirect Anchor provenance outputs.

Generate PROV Artifacts

To convert the captured canonical SQLite workflow database into PROV artifacts:

uv run python -m anchor.prov.mapper

Expected outputs:

.anchor/prov.json
.anchor/workflow_prov.png

The exporter reads ANCHOR_DB_PATH when it is set, otherwise ${ANCHOR_OUTPUT_PATH:-.anchor}/workflow_db.sqlite. Legacy JSON/TinyDB files are not migrated.

If PNG generation fails, install Graphviz:

brew install graphviz

Full Local Run

This is the complete sequence for the BeeAI phylogenetic subtrees case study:

cd anchor

brew install uv
brew install mafft
brew install ollama

export UV_PROJECT_ENVIRONMENT=venv
uv venv --python 3.12 venv
source venv/bin/activate
uv sync --extra beeai
cp .env.example .env

ollama serve

Then, in another terminal:

cd anchor

export UV_PROJECT_ENVIRONMENT=venv
ollama pull granite3.3:8b

uv run python -m examples.beeai.phylogenetic_subtrees.main
uv run python -m anchor.prov.mapper

If you already had a .venv before changing the package layout, the fastest temporary workaround is:

PYTHONPATH=src uv run python -c "import anchor; print(anchor.__version__)"
PYTHONPATH=src uv run python -m anchor.prov.mapper

The cleaner fix is to recreate the environment with a non-hidden directory:

rm -rf .venv
export UV_PROJECT_ENVIRONMENT=venv
uv venv --python 3.12 venv
source venv/bin/activate
uv sync --extra beeai --reinstall-package anchor-agentic-provenance

Status

Anchor is under active development. APIs and schemas may change while the project is being prepared for public release.

About

ANCHOR is a framework for capturing the provenance of multi-agent workflows using an interaction-centric approach.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages