Fona
Minimalist framework for background AI agents on PyAgentProlog.
An agent is a Prolog program plus Python actions. It runs as an HTTP server with a chat UI and a REST API, can talk to users and to other agents, and can be launched from a dashboard.
What it looks like
from fona import agent
@agent.action
def now_iso():
import time
return time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
@agent.program
PROGRAM = r"""
run :-
ui_print('Hello. Type "time" or "quit".'),
on_user_input.
on_user_input :-
ui_read(Input),
( Input == quit -> ui_print('Bye.')
; Input == time -> now_iso(T), ui_print(T), on_user_input
; ui_print('Unknown.'), on_user_input
).
"""
if __name__ == '__main__':
agent.run(port=8000)
python hello.py
# open http://127.0.0.1:8000/
Install
pip install pyagentprolog-fona
Python 3.10+. torch / sentence-transformers are optional ([torch], [semantic], [all]).
What you get
@agent.program— declare the agent's logic in Prolog.@agent.action/@agent.effect/@agent.generate— expose Python functions as Prolog predicates.agent.run()— serve a chat UI and a REST API (/api/v1/query,/api/v1/ui/*).- Prolog-only inter-agent protocol — peers call
/api/v1/querywith Prolog text; errors are"err:..."atoms, not exceptions. - Declarative config —
load_config(...)reads env once, returns an immutable object. - HF models —
Agent.from_hub("user/repo"); the user'sPROGRAMis prepended to the model's program. - Dashboard —
python -m fona.dashboard; a project is a folder holdingteam.json,scripts/,logs/. - Orchestrator UI —
python -m fona.orchestrator_app; three-column view of goal, plan, chat, subordinates. - Natural language ↔ Prolog — optional
@agent.actioncompanions to the HITL loop, not part of the protocol.
Documentation
The full guide — architecture, decorators, HITL, inter-agent protocol, query_one, REST contract, HF cache, dashboard, orchestrator, security, testing, releases, known limitations — lives in docs/guide.md
Start there. This README intentionally does not duplicate it.
Examples
| File | Shows |
|---|---|
examples/hello.py |
smallest agent: run/0 + ui_print |
examples/server_agent.py |
facts server + handle_request/2 (incoming) |
examples/client_agent.py |
call_peer/3 (outgoing) |
examples/template_agent.py |
reference: HITL, peers, protocol, NL ↔ Prolog, query_one |
examples/with_hf.py |
Agent.from_hub + prepended PROGRAM |
Protocol in one paragraph
Every agent can answer POST /api/v1/query with body {"query": "<Prolog text>"}. The response is {"success": bool, "solutions": [{"Var": value}], "count": int}. The recommended handler is handle_request(Kind, Payload) -> str with Kind ∈ {ping, echo, status}, extensible via register_protocol(agent, extra={...}). Outgoing calls use call_peer(Peer, Query) -> "ok:<v>" | "err:<r>", registered by register_peers(agent, CFG). Peers are configured via FONA_PEERS="name=url,...". No special language, no special client — just Prolog over HTTP.
Requirements
- Core:
fastapi,uvicorn,httpx,pydantic,transformers,huggingface_hub,pyagentprolog,pyagentprolog-hf. - Optional:
torch,sentence-transformers. - For private HF models:
FONA_HF_TOKEN. - For non-local bind:
FONA_TOKEN(REST auth) — see §16 of the guide.
Status
0.1.0 — in development. The public API and the inter-agent protocol are stable; the dashboard and orchestrator UI may change. Semver applies to Agent, agent, the decorators, and load_config / register_*.
License
See LICENSE.
One line: Fona lets you write an agent as a Prolog program plus Python actions, serve it over HTTP with a chat UI, and let it talk to other agents — all through one Prolog-only protocol. For everything else, read docs/guide.md
Metadata
Release files for pyagentprolog-fona 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyagentprolog_fona-0.1.0.tar.gz | 78.9 kB | Without provenance | Details for pyagentprolog_fona-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyagentprolog_fona-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pyagentprolog_fona-0.1.0-py3-none-any.whl |
Total release size: 157.8 kB
Release files / pyagentprolog_fona-0.1.0.tar.gz
| Download URL | pyagentprolog_fona-0.1.0.tar.gz |
|---|---|
| Size | 78.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
47d80840c9a93d7b9bf52e1e899603b09b97947a9d9b942e92ce1633d9904e4b
|
|
BLAKE2b-256 checksum How to use checksums |
fb00df95e0d400c9e00a728962c218c7ebe5bde14bc5e70b3b4a029f5b9be5a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Release files / pyagentprolog_fona-0.1.0-py3-none-any.whl
| Download URL | pyagentprolog_fona-0.1.0-py3-none-any.whl |
|---|---|
| Size | 78.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
79302f5f02ecfd964b327a3a7f84911715e2d73f11bed0cdbc015362f99d0e9f
|
|
BLAKE2b-256 checksum How to use checksums |
9189989678a3591aebd40383ccc8edd5f49f1bfea1d72f9d35bbcd1d63d7e84f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Security for pyagentprolog-fona 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.