Import policy
AFK follows three rules for its public API surface: 1. Prefer public package exports. Every AFK package defines an__all__ list in its __init__.py file. These exports are the public API. Import from the package level rather than reaching into internal sub-modules.
__init__.py exports are the stable contract. If you import from the package level, your code survives internal refactors without changes.
2. Avoid importing private or internal modules. Any module with a leading underscore (_helpers.py), or any path containing _internal or _private, is not part of the public API. These modules exist to support the framework’s internal implementation and may change without notice.
3. Keep interfaces contract-first and explicit. When extending AFK (implementing custom tools, assertions, interaction providers, etc.), implement the documented protocol interfaces rather than subclassing internal classes. Protocol-based contracts are stable; internal class hierarchies are not.
Canonical import patterns by use case
Agent definition and execution
Policy and security
Tool development
LLM client (direct usage)
Delegation and subagents
A2A protocol
Eval suite
Observability
Interaction providers
Streaming
Memory
Errors
Migration guide
If you have existing code that imports from internal module paths, use this table to find the correct public import:| Internal Import (avoid) | Public Import (use instead) |
|---|---|
from afk.agents.core.base import Agent | from afk.agents import Agent |
from afk.agents.types.result import AgentResult | from afk.agents import AgentResult |
from afk.agents.policy.engine import PolicyEngine | from afk.agents import PolicyEngine |
from afk.core.runner.api import RunnerAPIMixin | from afk.core import Runner |
from afk.core.runner.types import RunnerConfig | from afk.core import RunnerConfig |
from afk.llms.builder import LLMBuilder | from afk.llms import LLMBuilder |
from afk.llms.types import LLMRequest | from afk.llms import LLMRequest |
from afk.evals.suite import run_suite | from afk.evals import run_suite |
from afk.evals.budgets import EvalBudget | from afk.evals import EvalBudget |
from afk.tools.core.base import ToolResult | from afk.tools import ToolResult |
from afk.*.*. (three or more dots of depth) and check whether a shallower public import exists.