Skip to main content

Horizon Agent

A local reference implementation of the Horizon Agent research concept: a persistent agent that retrieves evidence-linked memory, maintains goals, plans bounded tool use, checks permissions outside the language model, records checkpoints, and verifies tool outcomes.

This package is intentionally small and inspectable. It uses Python's standard library and SQLite. It does not ship web, shell, email, or other external-action tools. The optional model adapter talks to an OpenAI-compatible chat-completions endpoint only when configured; without a model it remains usable for memory and goal management and provides a transparent offline response.

Quick start

Requires Python 3.10 or later.

cd horizon_agent
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -e .
horizon-agent goals create "Develop Horizon Agent" --description "Build and evaluate a reliable persistent agent"
horizon-agent memory add "The project uses checkpointed actions and provenance-linked memory." --tags research design
horizon-agent ask "What project context do you remember?"

On macOS or Linux, activate with source .venv/bin/activate.

The default database is ~/.horizon_agent/horizon.sqlite3. Set HORIZON_DB or pass --db PATH to choose another location. The --db option must appear before the subcommand.

Optional model backend

Set HORIZON_MODEL and HORIZON_API_KEY for a hosted OpenAI-compatible endpoint. HORIZON_API_BASE defaults to https://api.openai.com/v1. A local endpoint can omit the key when its URL starts with http://localhost or http://127.0.0.1.

$env:HORIZON_MODEL = "your-json-capable-model"
$env:HORIZON_API_KEY = "your-key"
# Optional: $env:HORIZON_API_BASE = "https://your-provider.example/v1"
horizon-agent ask "Summarize my open goals and suggest a next step."

The model receives the current request, retrieved memories with source IDs, open goals, and the built-in tool descriptions. Model-suggested writes pass through the local policy gate. No request is sent unless a model is configured and ask is used.

Commands

horizon-agent ask "..."
horizon-agent memory add "..." [--scope SCOPE] [--confidence 0.0..1.0] [--valid-until ISO] [--tags ...]
horizon-agent memory search "query"
horizon-agent memory list [--all]
horizon-agent memory invalidate MEMORY_ID "reason" [--disputed]
horizon-agent goals create "title" [--description ...] [--criteria ...] [--priority 1..5]
horizon-agent goals list [--status open|in_progress|blocked|completed|cancelled]
horizon-agent goals update GOAL_ID [--status ...] [--description ...] [--criteria ...] [--priority 1..5]
horizon-agent approvals list
horizon-agent approvals approve PROPOSAL_ID
horizon-agent approvals deny PROPOSAL_ID [--reason ...]
horizon-agent permission grant 'goal.*' allow|approval|deny [--scope SCOPE] [--context CONDITION] [--expires-at ISO]
horizon-agent permission list
horizon-agent runs [--limit N]
horizon-agent checkpoints RUN_ID
horizon-agent events [--limit N]

Writes require a one-action approval unless the user grants a matching, bounded allow rule. deny rules take precedence over tools' default policy. External or high-impact tools always require one-action approval even when an allow rule matches. Permission rules are local policy records, not authentication; protect the database and host account.

Permission context conditions

A permission can carry a --context condition: semicolon-separated clauses checked against the action's own arguments. All clauses must hold for the rule to apply.

key = value          the argument equals value
key != value         the argument differs from value
key ^= p1|p2         the argument starts with one of the prefixes
key in a|b|c         the argument equals one of the listed values

For a list argument, every element must satisfy the clause. A missing or empty argument makes the condition unknown rather than true: an allow rule does not apply, while a deny or approval rule does (fail closed). A clause that is violated makes the whole condition false. Example:

horizon-agent permission grant repo.push allow --scope docs/ --context "paths ^= docs/; ci = green"

A malformed condition is rejected when the permission is granted. If a stored condition cannot be parsed, allow rules stop applying while deny and approval rules stay in force. Among the rules that apply, a narrower scope wins first, then a more specific tool pattern (an exact name over a wildcard, then more literal characters), then the newer rule. Exact ties go to the most restrictive mode (deny, then approval, then allow).

The arguments are proposed by the language model, so a condition on a fact the model reports (such as ci) is only as trustworthy as that report. A tool can instead declare derive_facts, a function that computes such facts from its own view of the world (for example, the changed paths of a branch). Derived values override same-named arguments when conditions are checked. A disagreement is logged as authorization.fact_mismatch, and a derivation that raises is logged as authorization.fact_error and fails closed (the model's claims are then ignored). A derived scope also replaces the model's, so a scoped permission or prohibition cannot be dodged by naming a different scope. A derived value of None marks a fact as unknown: the model's claim for it is discarded, so no condition on it can hold. Facts the tool does not return stay as the model reported them, and so does the scope if the tool does not derive it. High-impact and external tools still require per-action approval even when an allow rule and its condition match.

Structure

  • horizon_agent/agent.py — observe, retrieve, plan, authorize, execute, verify, and respond loop.
  • horizon_agent/store.py — SQLite events, memories, goals, permissions, runs, checkpoints, proposals, tool records, and notes.
  • horizon_agent/memory.py — lexical retrieval with active/expiry filtering, scope, confidence, and provenance.
  • horizon_agent/policy.py — independent default-deny allowlist and approval gate.
  • horizon_agent/tools.py — built-in local tools and restricted arithmetic evaluator.
  • horizon_agent/model.py — optional OpenAI-compatible JSON chat adapter.
  • horizon_agent/cli.py — command-line interface.

The action cycle records its request, retrieved evidence, plan inputs, policy decisions, tool outcomes, verification results, and checkpoints. Memory records refer to a source event. The verifier checks persisted state for supported writes before the agent reports success.

Research and implementation limits

This is a prototype for experimentation, not a production agent platform. Retrieval is lexical BM25-style scoring rather than semantic retrieval; model quality depends on the configured provider; the verifier uses deterministic state checks for the included tools; and no multi-user identity, encryption-at-rest, distributed execution, or external integrations are included. Approval is a local CLI action. Benchmarking and adversarial evaluation should be conducted before making reliability claims.

Tests

test_delegation_example.py replays the worked example from the manuscript (Section 6.6) through the real gate, approval queue, execution path, and verifier, with a scripted stand-in for the language model. It also unit-tests the permission context conditions. No network access is used.

cd agent
python -m unittest test_delegation_example -v

evaluate_delegation_scenarios.py scores the policy gate on 33 labeled scenarios (3 tools by 11 authority states) against two simple baselines and writes delegation_scenarios_results.json. The labels come from the formal rule in the manuscript, not from the gate's code, and were written by the manuscript's author team.

python evaluate_delegation_scenarios.py

evaluate_endtoend.py runs the same scenarios with a planner (a stand-in, or a real model through the optional adapter) proposing the actions while the real gate decides. The stub: planners validate the harness and are not model results. make_annotation_packet.py and score_annotations.py support the independent-annotation protocol in replication/annotation/.

check_gate_properties.py generates random policies and requests (20,000 by default) and checks the gate against an independent oracle and ten invariants; test_gate_properties.py runs a 300-case version as a regression test. check_gate_exhaustive.py enumerates every ordered pair of rules from a 648-rule alphabet (420,553 policies, about 10 million decisions, about two minutes) and checks the gate against the same oracle; test_gate_exhaustive.py runs a slice of it.

python evaluate_endtoend.py --planner stub:faithful stub:wrongscope --repeats 3
python check_gate_properties.py 20000
python check_gate_exhaustive.py
python -m unittest test_delegation_example test_score_annotations test_gate_properties test_gate_exhaustive -v

tools_mock_openai_server.py is a local OpenAI-compatible stand-in that follows a fixed rule. Use it only to test the model path without a network (python tools_mock_openai_server.py 8765, then set HORIZON_API_BASE=http://127.0.0.1:8765/v1 and HORIZON_MODEL=mock). Its results are not model results.

License

MIT. See LICENSE.

Metadata

Release files for horizon-agent 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for horizon-agent 0.2.0
File Size Uploaded Provenance Actions
horizon_agent-0.2.0.tar.gz 27.2 kB Without provenance Details for horizon_agent-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for horizon-agent 0.2.0
File Interpreter ABI Platform Actions
horizon_agent-0.2.0-py3-none-any.whl Python 3 none any Details for horizon_agent-0.2.0-py3-none-any.whl

Total release size: 54.7 kB

Release files / horizon_agent-0.2.0.tar.gz

Download URL horizon_agent-0.2.0.tar.gz
Size 27.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a4110f62e6d969cc0fa54883fbdfe604585aadc9498902e26f082e9a4b737758
BLAKE2b-256 checksum
How to use checksums
5ecbcc0dd66213f2dd4ca539f188c3cb582f16f73a33097d52afd2df73823f0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Release files / horizon_agent-0.2.0-py3-none-any.whl

Download URL horizon_agent-0.2.0-py3-none-any.whl
Size 27.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b86b249d81c2d308b5ee34788617f1300532f0a1bf963e7dd93017c23071d7e2
BLAKE2b-256 checksum
How to use checksums
aab85c7840588a215ca5ea6fcdb1f1c26e967bee74e24b11d086a1ee66af1c4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Security for horizon-agent 0.2.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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page