API Reference

May 8, 2026 ยท View on GitHub

The amplifier-foundation API is fully documented via Python docstrings and type hints. This overview lists what's exported; for details, read the source files directly.

Why this approach? Documentation that duplicates code becomes context poisoning when it drifts. The code IS the authoritative reference.

Quick Import

from amplifier_foundation import Bundle, BundleRegistry, load_bundle

Core Classes

ExportSourcePurpose
Bundlebundle.pyComposable unit with mount plan config
BundleRegistryregistry.pyNamed bundle management and loading
BundleValidatorvalidator.pyBundle structure validation
ValidationResultvalidator.pyValidation result with errors/warnings
BundleStateregistry.pyTracked state for loaded bundles
UpdateInforegistry.pyAvailable update information

Convenience Functions

ExportSourcePurpose
load_bundleregistry.pyLoad bundle from URI
validate_bundlevalidator.pyValidate bundle, return result
validate_bundle_or_raisevalidator.pyValidate bundle, raise on error

Exceptions

ExportSourcePurpose
BundleErrorexceptions.pyBase exception
BundleNotFoundErrorexceptions.pyBundle not found
BundleLoadErrorexceptions.pyBundle load/parse failed
BundleValidationErrorexceptions.pyValidation failed
BundleDependencyErrorexceptions.pyDependency resolution failed

Protocols

ExportSourcePurpose
MentionResolverProtocolmentions/protocol.py@mention resolution contract
SourceResolverProtocolsources/protocol.pyURI resolution contract
SourceHandlerProtocolsources/protocol.pySource type handler contract
CacheProviderProtocolcache/protocol.pyCache provider contract

Reference Implementations

ExportSourcePurpose
BaseMentionResolvermentions/resolver.pyDefault @mention resolver
SimpleSourceResolversources/resolver.pyGit/file source resolver
SimpleCachecache/simple.pyIn-memory cache
DiskCachecache/disk.pyPersistent disk cache

Mentions

ExportSourcePurpose
parse_mentionsmentions/parser.pyExtract @mentions from text
load_mentionsmentions/loader.pyLoad @mention content (async)
ContentDeduplicatormentions/deduplicator.pySHA-256 content deduplication
ContextFilementions/models.pyLoaded context file data
MentionResultmentions/models.py@mention resolution result

I/O Utilities

ExportSourcePurpose
read_yamlio/yaml.pyRead YAML file (async)
write_yamlio/yaml.pyWrite YAML file (async)
parse_frontmatterio/frontmatter.pyParse YAML frontmatter
read_with_retryio/files.pyRead with cloud sync retry (async)
write_with_retryio/files.pyWrite with cloud sync retry (async)

Dict Utilities

ExportSourcePurpose
deep_mergedicts/merge.pyDeep merge dictionaries
merge_module_listsdicts/merge.pyMerge module lists by ID
get_nesteddicts/navigation.pyGet nested dict value by path
set_nesteddicts/navigation.pySet nested dict value by path

Path Utilities

ExportSourcePurpose
parse_uripaths/resolution.pyParse source URI
ParsedURIpaths/resolution.pyParsed URI dataclass
normalize_pathpaths/resolution.pyNormalize/resolve path
construct_agent_pathpaths/construction.pyBuild agent file path
construct_context_pathpaths/construction.pyBuild context file path
find_filespaths/discovery.pyFind files by pattern (async)
find_bundle_rootpaths/discovery.pyFind bundle root upward (async)

Session Capabilities

ExportSourcePurpose
get_working_dirsession/capabilities.pyGet session working directory from coordinator
set_working_dirsession/capabilities.pyUpdate session working directory dynamically
WORKING_DIR_CAPABILITYsession/capabilities.pyCapability name constant ("session.working_dir")

Spawn Utilities

Utilities for spawning sub-sessions with provider/model preferences.

ExportSourcePurpose
ProviderPreferencespawn_utils.pyDataclass for provider/model preference (supports glob patterns)
apply_provider_preferencesspawn_utils.pyApply ordered preferences to mount plan
resolve_model_patternspawn_utils.pyResolve glob patterns (e.g., claude-haiku-*) to concrete model names
is_glob_patternspawn_utils.pyCheck if model string contains glob characters

Cost Bridge Utilities

Utilities for propagating child-session costs to parent coordinators in app-layer spawn wrappers. Import via from amplifier_foundation import ....

ExportSourcePurpose
bridge_child_costbundle/_prepared.pyCollect child session's session.cost contributions and register them as a single contributor on the parent coordinator. Never raises โ€” errors are logged as warnings.
sum_cost_usdbundle/_prepared.pySum a list of collect_contributions() results into a single Decimal | None. Returns None when no cost data is present. Tolerates both Decimal and str values.

Reading the Source

Each source file has comprehensive docstrings. To read them:

# In your editor
code amplifier_foundation/bundle.py

# Or via Python
python -c "from amplifier_foundation import Bundle; help(Bundle)"

# Or via pydoc
python -m pydoc amplifier_foundation.Bundle

Common Patterns

Load and Use a Bundle

from amplifier_foundation import load_bundle

bundle = await load_bundle("git+https://github.com/org/my-bundle@main")
mount_plan = bundle.to_mount_plan()

Compose Bundles

from amplifier_foundation import load_bundle

base = await load_bundle("foundation")
overlay = await load_bundle("./local-overlay.md")
composed = base.compose(overlay)

Registry Management

from amplifier_foundation import BundleRegistry

registry = BundleRegistry()
registry.register({"my-bundle": "git+https://github.com/org/bundle@main"})
bundle = await registry.load("my-bundle")

Load @Mentions

from amplifier_foundation import load_mentions, BaseMentionResolver

resolver = BaseMentionResolver(bundles={"foundation": foundation_bundle})
results = await load_mentions("See @foundation:context/guidelines.md", resolver)