Python Component Agent
Build an Akshi agent in Python using WIT bindings and componentize-py.
Prerequisites
- Python 3.11+
componentize-pyinstalled (pip install componentize-py)- Akshi CLI installed
Create the project
akshi create agent my-py-agent --lang python
cd my-py-agent
Project structure
my-py-agent/
app.py
wit/
deps/
world.wit
Write agent logic
Edit app.py:
from akshi_sdk import Agent, Context
class MyPyAgent(Agent):
def tick(self, ctx: Context):
logs = ctx.db_query("SELECT * FROM events WHERE level = 'error'")
if logs:
summary = ctx.infer(f"Summarize these errors: {logs}")
ctx.journal_insert("error-summary", summary)
Build
componentize-py -d wit/world.wit -w agent componentize app -o my_py_agent.wasm
Configure
[[agents]]
name = "my-py-agent"
wasm_path = "my_py_agent.wasm"
tick_interval_secs = 300
fuel_limit = 2_000_000
[agents.capabilities]
inference = true
journal = true
database = true
Run
akshi run
Limitations
- Python components are larger (~5 MB) due to the embedded interpreter.
- Startup time is higher than Rust agents. The runtime caches the compiled module after the first load.
- Not all Python standard library modules are available in the WASM environment.
Next steps
- Using the SDK for database, journal, and inference patterns
- Host Capabilities for capability declarations