Architecture
python-agent-runtime is a small execution layer. It coordinates independent
components rather than owning every AI concern.
Component Model
Agentis the public facade used by applications.Runtimeowns the execution loop.PromptBuilderconstructs chat messages.ConversationHistorystores user and assistant turns.Memoryis an optional protocol for recalled context.ToolRegistrystores tools andToolExecutorinvokes them.CallbackManageremits lifecycle events.RuntimeConfigkeeps behavior explicit.
Execution Flow
Agent.run()delegates toRuntime.- The runtime recalls optional memory.
- If a
rag.RAGinstance is present, the runtime callsRAG.retrieve(...). PromptBuildercreates system, history and user messages.- The LLM adapter is called.
- Structured tool calls are executed when returned.
- The final response is saved to history and memory.
RAG Boundary
The official retrieval backend is python-rag-framework. The runtime relies on
its public retrieval API:
results = rag.retrieve(
query,
limit=4,
metadata_filter={"language": "ko"},
)
Results are rag.SearchResult models containing chunk.text,
chunk.metadata, and score.
The runtime does not duplicate ingestion, loaders, chunking, embeddings, vector
stores, reranking, citations or RAG.ask() generation. Its role is to place
retrieved context into the agent prompt.
LLM Boundary
The runtime defines a small protocol:
def complete(messages, *, tools=None) -> str | object: ...
Adapters can be application-specific. The package includes CallableLLM and
OpenAIChatLLM for common use cases.
Design Principles
- Prefer composition over inheritance.
- Keep the public API small.
- Keep provider and retrieval integrations optional.
- Make the execution loop predictable.
- Avoid workflow graphs, schedulers and orchestration engines.