Skip to main content
The Agent Forge Kit (AFK) Python SDK is organized into a set of top-level packages, each owning a distinct responsibility. This page provides a comprehensive inventory of every package, its sub-modules, key classes and functions, and example imports. Use this reference when you need to find where a comprehensive inventory of every package, its sub-modules, key classes and functions, and example imports.

Module dependencies

The AFK architecture is layered. Dependencies flow strictly downwards:
  • afk.agents (High-level definitions) -> depends on afk.core, afk.tools, afk.llms
  • afk.core (Execution engine) -> depends on afk.model, afk.memory, afk.observability
  • afk.llms (Provider I/O) -> independent
  • afk.tools (Capabilities) -> independent

Extension points

The framework is designed to be extended at specific protocol boundaries. Do not subclass internal classes. Instead, implement these protocols:
  • InteractionProvider (afk.core): Build custom human-in-the-loop interaces (e.g. Slack, Discord, Web).
  • MemoryStore (afk.memory): Add support for new databases (Mongo, DynamoDB).
  • LLMProvider (afk.llms): Integrate new model providers (local inference, exotic APIs).
  • TelemetrySink (afk.observability): Export metrics/traces to custom backends (Datadog, Honeycomb).

afk.agents

Agent definitions, lifecycle types, delegation, policy, A2A protocol, and error hierarchy. Sub-modules:
Sub-moduleResponsibility
afk.agents.coreAgent and BaseAgent definitions, ChatAgent variant.
afk.agents.typesRuntime types: AgentResult, AgentRunEvent, AgentRunHandle, AgentState, PolicyEvent, PolicyDecision, FailSafeConfig, UsageAggregate, execution records.
afk.agents.policyPolicyEngine, PolicyRule, PolicyEvaluation, policy subject inference.
afk.agents.delegationDelegationPlan, DelegationNode, DelegationEdge, RetryPolicy, JoinPolicy, DelegationResult.
afk.agents.a2aInternalA2AProtocol, A2A auth providers (AllowAllA2AAuthProvider, APIKeyA2AAuthProvider, JWTA2AAuthProvider), A2AServiceHost, delivery stores.
afk.agents.contractsAgentCommunicationProtocol, AgentInvocationRequest, AgentInvocationResponse, AgentDeadLetter.
afk.agents.promptsPromptStore, prompt file resolution, template rendering.
afk.agents.lifecycleCheckpoint versioning, schema migration, runtime helpers (circuit breaker, effect journal, state snapshots).
afk.agents.skillsSkillStore, SkillDoc, SKILL.md parsing, checksum verification, and process-wide caching.
afk.agents.securityPrompt-injection sanitization, untrusted tool-output redaction, and channel markers for trusted vs untrusted content.
afk.agents.errorsFull error hierarchy: AgentError, AgentExecutionError, AgentCancelledError, SubagentRoutingError, etc.
Key imports:
from afk.agents import Agent, AgentResult, AgentRunEvent, PolicyEngine, PolicyRule
from afk.agents import DelegationPlan, DelegationNode, FailSafeConfig
from afk.agents import JWTA2AAuthProvider, A2AServiceHost

afk.core

Runner execution engine, streaming, interaction providers, and delegation engine. Sub-modules:
Sub-moduleResponsibility
afk.core.runnerRunner class with run(), run_sync(), run_handle(), run_stream(), resume(), compact_thread(). RunnerConfig for safety and behavior defaults.
afk.core.streamingAgentStreamHandle, AgentStreamEvent, stream event constructors (text_delta, tool_started, stream_completed).
afk.core.interactionInteractionProvider protocol, HeadlessInteractionProvider, InMemoryInteractiveProvider.
afk.core.runtimeDelegationEngine, DelegationPlanner, DelegationScheduler, backpressure and graph validation.
Key imports:
from afk.core import Runner, RunnerConfig
from afk.core import AgentStreamHandle, AgentStreamEvent
from afk.core import InteractionProvider, HeadlessInteractionProvider
from afk.core import DelegationEngine

afk.llms

LLM client builder, provider registry, runtime policies, caching, routing, middleware, and type definitions. Sub-modules:
Sub-moduleResponsibility
afk.llms.builderLLMBuilder — fluent builder for constructing LLM client instances.
afk.llms.providersProvider registry: OpenAIProvider, LiteLLMProvider, AnthropicAgentProvider, register_llm_provider().
afk.llms.runtimeLLMClient with production policies: RetryPolicy, TimeoutPolicy, RateLimitPolicy, CircuitBreakerPolicy, HedgingPolicy, CachePolicy.
afk.llms.routingRouter registry: create_llm_router(), register_llm_router().
afk.llms.cacheCache backends: create_llm_cache(), in-memory and Redis implementations.
afk.llms.middlewareMiddlewareStack for request/response transformation pipelines.
afk.llms.typesLLMRequest, LLMResponse, Message, ToolCall, Usage, streaming event types.
afk.llms.configLLMConfig dataclass for model configuration.
afk.llms.profilesProduction/development profile presets.
afk.llms.errorsLLMError, LLMTimeoutError, LLMRetryableError, etc.
Key imports:
from afk.llms import LLMBuilder, LLMClient, LLMRequest, LLMResponse, Message
from afk.llms import RetryPolicy, TimeoutPolicy, CircuitBreakerPolicy
from afk.llms import LLMConfig, LLMSettings, PROFILES

afk.tools

Tool definition, registry, hooks, middleware, security, and prebuilt runtime tools. Sub-modules:
Sub-moduleResponsibility
afk.tools.coretool decorator, ToolSpec, ToolContext, ToolResult, ToolRegistry.
afk.tools.securitySandboxProfile, SandboxProfileProvider, SecretScopeProvider, argument validation.
afk.tools.prebuiltsBuilt-in runtime tools (file read, directory list, command execution, skill tools).
afk.tools.hooksPre/post execution hook system for tool middleware.
Key imports:
from afk.tools import tool, ToolResult, ToolContext
from afk.tools.security import SandboxProfile, SecretScopeProvider

afk.memory

Pluggable memory stores, compaction, retention policies, long-term memory, vector search, and thread state persistence. Sub-modules:
Sub-moduleResponsibility
afk.memory.storeMemoryStore abstract base class, MemoryCapabilities declarations.
afk.memory.typesMemoryEvent, LongTermMemory, JsonValue, retention policy models.
afk.memory.lifecycleapply_event_retention(), apply_state_retention(), compact_thread_memory(), MemoryCompactionResult.
afk.memory.vectorcosine_similarity(), vector scoring utilities for embedding-based search.
afk.memory.factorycreate_memory_store() factory for environment-based backend selection.
afk.memory.adaptersBackend implementations: InMemoryMemoryStore, SQLiteMemoryStore, PostgresMemoryStore, RedisMemoryStore.
Key imports:
from afk.memory import MemoryStore, RetentionPolicy, compact_thread_memory
from afk.memory import InMemoryMemoryStore
from afk.memory.adapters.sqlite import SQLiteMemoryStore
from afk.memory.adapters.postgres import PostgresMemoryStore
from afk.memory.adapters.redis import RedisMemoryStore
from afk.memory.types import MemoryEvent, LongTermMemory

afk.queues

Task queue abstraction, worker lifecycle, failure classification, and metrics. Sub-modules:
Sub-moduleResponsibility
afk.queues.baseBase queue types and enqueue/dequeue contracts.
afk.queues.contractsQueue protocol definitions.
afk.queues.factoryQueue backend factory for creating queue instances.
afk.queues.workerWorker lifecycle management and task dispatch.
afk.queues.metricsQueue-level operational metrics.
Key imports:
from afk.queues import QueueWorker, TaskQueue

afk.observability

Telemetry collection, projection, and export for runtime monitoring. Sub-modules:
Sub-moduleResponsibility
afk.observability.modelsRunMetrics dataclass with aggregated run statistics.
afk.observability.contractsSpan and metric name constants (SPAN_AGENT_RUN, METRIC_AGENT_LLM_CALLS_TOTAL, etc.).
afk.observability.projectorsProjection functions that transform run results into RunMetrics.
afk.observability.exportersConsoleRunMetricsExporter and other output formatters.
afk.observability.backendsTelemetry sink creation (create_telemetry_sink).
Key imports:
from afk.observability.models import RunMetrics
from afk.observability.contracts import SPAN_AGENT_RUN, METRIC_AGENT_LLM_CALLS_TOTAL
from afk.observability.exporters.console import ConsoleRunMetricsExporter

afk.evals

Eval suite execution, assertion contracts, budget constraints, and report serialization. Sub-modules:
Sub-moduleResponsibility
afk.evals.suiterun_suite() and arun_suite() entrypoints.
afk.evals.executorSingle-case execution via run_case() and arun_case().
afk.evals.modelsEvalCase, EvalCaseResult, EvalSuiteConfig, EvalSuiteResult, EvalAssertionResult.
afk.evals.contractsEvalAssertion, AsyncEvalAssertion, EvalScorer protocols.
afk.evals.budgetsEvalBudget dataclass and evaluate_budget() function.
afk.evals.reportingsuite_report_payload(), write_suite_report_json().
afk.evals.goldenwrite_golden_trace(), compare_event_types() for deterministic trace comparison.
Key imports:
from afk.evals import run_suite, EvalBudget
from afk.evals.models import EvalCase, EvalSuiteConfig, EvalSuiteResult
from afk.evals.reporting import write_suite_report_json
from afk.evals.golden import compare_event_types

afk.mcp

Model Context Protocol server implementation, tool store, and server registration. Sub-modules:
Sub-moduleResponsibility
afk.mcp.serverMCP protocol handler.
afk.mcp.storeTool store registry and utility functions for MCP tool loading.
Key imports:
from afk.mcp import get_mcp_store

afk.messaging

Internal agent-to-agent messaging primitives with delivery guarantees. Sub-modules:
Sub-moduleResponsibility
afk.messaging.busMessageBus protocol for pub/sub messaging between agents.
afk.messaging.deliveryDelivery tracking, acknowledgment, and retry for inter-agent messages.
afk.messaging.typesAgentMessage, MessageEnvelope, delivery status types.
Key imports:
from afk.messaging import MessageBus, AgentMessage