aicf-core · Apache-2.0 · Python 3.10+ · local-first
The floor that makes
an agent unkillable.
aicf is agent infrastructure specialized for one job: companion systems that stay online for the long haul and respond the moment you speak. It assumes the process will die — a crash, a power cut, a deploy restart — and the task still finishes.
A system like that cannot go down with the machine or drop a sentence mid-conversation — so the floor under it must be unkillable and always awake. The floor, not the app.
pip install aicf-core
This repo contains only two library layers: aicf/harness (the agent core) and
aicf/infra (models, resources, storage, policy). The web console lives in a
separate repo, aicf-ui.
- Safepolicy gates · human approval · path scope · undecided means denied
- Unkillablekill -9 recoverable · side effects never replayed · 46/46 fault-injection recoveries
- Measurabletrace → dataset scoring → four-gate report
What's in the floor
The floor is the layer your agent system stands on. Everything below lives in it — and because all of it lives there, it can carry a companion system that stays online for the long haul and answers on the first word. Every item carries its module path, so you can go check it yourself.
Full-modal: text · speech · vision
Local speech and vision models run in the same pool: ASR (FunASR, in-process), TTS (GPT-SoVITS, over HTTP), VLM (a local llama-server). Scheduled by slot, launched on demand; idle past a threshold they are stopped automatically, their VRAM handed back, and relaunched on the next request.
- aicf/infra/resources/
- aicf/harness/voice/
- ResourcePool
- IdleReaper
- SentenceStreamSpeaker
Text models route through aicf/infra/models/ and aicf/infra/orchestrator/;
the VRAM-exclusive gate (DeviceGate) lives in aicf/infra/orchestrator/scheduler.py —
when training and inference contend for the same cards, exactly one of them decides. The
always-available-vs-VRAM tradeoff is explicit: the three tiers of aicf resources profile
(resident / balanced / eco).
The interaction layer has also sunk into the framework: a voice layer at aicf/harness/voice —
sentence-streamed TTS playback (it starts speaking as soon as the first sentence is synthesized),
fake-speech filtering, a perception mode (a continuous call where silence means listening), and
heartbeat proactive speech. Full-modal is now interactive — not just resource management.
Multi-agent: as many as the task needs
Role types, delegation, mailboxes, and settlement live in collab.py; peer collaboration
adds a shared blackboard in swarm.py; team.py folds them into a single call;
master→subagent concurrent decomposition is subagent.py.
- aicf/harness/agent/collab.py
- aicf/harness/agent/swarm.py
- aicf/harness/agent/team.py
- aicf/harness/agent/subagent.py
Identity and authorization live in aicf/infra/control/identity.py: an AgentIdentity
carries a full delegation_chain, a child scope must be a subset of its parent scope, and
stepping outside it is rejected; every delegation leaves a DelegationAudit.
Ecosystem: skill packs are external and declarative
Skill packs live outside the repo: one skill.yaml declares tools, prompts, and
dependencies, plus plain Python. The framework validates them before an agent ever sees them —
if a class, method, parameter, or dependency does not line up, it says so up front instead of
blowing up at call time.
- aicf/harness/skills/
- Skill / SkillRegistry
- SkillLoader
- SkillValidator
- CapabilityRegistry
Declarative loading is in aicf/harness/skills/yaml_loader.py; runtime install / enable /
disable / append-skill-directory is in aicf/harness/skills/yaml_manager.py — installing a
new skill does not require restarting the app.
Long-running + persistent: a crash does not end the run
The journal is the source of truth; checkpoints are only an accelerator. Idempotency keys keep
effectful calls from being replayed; leases + fencing tokens let another instance take
over without two instances ever writing at once.
- aicf/infra/runtime/
- journal / checkpoint
- idempotency / recovery
- lease + fencing token
Memory is layered — working / episodic / semantic / profile — in aicf/harness/memory/
(L0–L3; L3 is injected only with explicit authorization); persistence lands in aicf/infra/store/.
Three promises — and how to check them yourself
You don't have to take the docs at their word. Each promise has a command or a test behind it; run it and you'll know.
| Promise | What it actually guarantees | How to check it yourself |
|---|---|---|
| Safe |
Every tool call passes a policy gate; tools with side effects require
human approval; a tool that starts processes is checked before it runs —
path scope and egress targets, ulimits, only whitelisted environment variables passed
through — but it still runs with the operator's privileges (not
an OS-level sandbox, and no containers / microVMs); undecided means denied
(deny-by-default).
The policy protocol is in |
→ Denied by policy with a non-zero exit code; a pending approval counts as a denial too. |
| Unkillable |
After kill -9 the process recovers, and side effects that already happened
are not repeated; effectful calls are never auto-replayed. The journal is the
truth; checkpoints are only an accelerator. Fault injection with a real kill -9:
46/46 recovered.
The source of truth is in |
→ Really kills a subprocess with kill -9, then recovers from the journal; |
| Measurable |
Every run produces a trace; changes can be scored against a dataset;
a four-gate report blocks regressions, cost overruns, and rule violations.
The four gates are in |
→ Four gates: quality / regression / cost / safety. Any gate failing blocks a release; the safety gate has zero tolerance. |
Quickstart in 90 seconds
Every step below runs offline — no API key anywhere — and the walkthrough ends green.
-
01
Install it
pip install aicf-coreDistribution name
aicf-core, CLI entry pointaicf, import nameaicf.*. -
02
Scaffold a project
aicf init demo && cd demoEntry points wired, no business logic — fill in the meat.
-
03
Read the tool catalog: effect level, declared write level, required scopes
aicf tool list # your own tools are visibleKnow what each tool can do before you decide which ones an agent may use.
-
04
Try a call that gets denied
aicf tool exec proc.run --args '{"command":"rm -rf /"}' --policy strict # → denied: waits for a humanA tool with side effects does not start on its own. Under a strict policy the call is denied and waits for a human — a pending approval counts as a denial too.
-
05
Run the offline dataset
aicf run --dataset offline --trace-dir traces/ # one trace per caseOne turn per case, one trace per case. Traces are JSONL, one event per line — the scoring step runs on them.
-
06
Score it
aicf eval --dataset offline --traces traces/ --out run.json # 6/6 passedrun.jsonrecords the run. On the offline dataset the bundled stub model scores 6/6. -
07
Ship the gate report
aicf gate --run run.json --out gate.json # verdict: passgate.jsonholds the per-gate verdicts — quality, regression, cost, safety. Look at this report before any release. The walkthrough ends green.
Two datasets ship with the package — on purpose:
offline — pipeline smoke
A reply arrives, no phantom tool calls, budget fields recorded. It passes with the bundled stub model by design — it tells you the floor works.
basic — 40 quality cases
File io, computation, out-of-scope refusal, safety, format, multi-step. It needs a real
model: the stub never calls tools, and the eval engine refuses to count an echo as an
answer. aicf eval --group refusal,safety scores a subset — the run record shows
which subset was scored.
Python quickstart
Three symbols: tool, create_agent, Agent. Any OpenAI-compatible
endpoint works; for local models point base_url at llama-server / LM Studio.
from aicf.harness import create_agent, tool
@tool
def add(a: int, b: int) -> int:
"""Add two numbers."""
return a + b
agent = create_agent(
model="deepseek-chat",
base_url="https://api.deepseek.com/v1",
api_key="sk-...", # or just export OPENAI_API_KEY
tools=[add],
)
print(agent.run("what is 17 + 25?"))
Common imports
from aicf.harness import create_agent, tool, Agent
from aicf.harness.tools import ToolRegistry
from aicf.infra.models.base import IChatClient
Use ToolRegistry when you manage the tool table yourself; implement IChatClient to plug in your own backend.
Runs offline too
aicf run --dataset offline --trace-dir traces/
aicf eval --dataset offline \
--traces traces/ --out run.json
With no API key configured, the CLI falls back to the bundled stub model and the eval loop
still closes — the offline smoke dataset passes by design. The basic quality
dataset needs a real model: the stub does not call tools.
Architecture: bottom-up, dependencies point down
This repo is the bottom two layers — aicf/harness and aicf/infra. Before
adding code, answer one question: does it care about business semantics, or only about resources?
Skill packs and your application grow on top of it, but dependencies still point one
way, down: upper layers know lower layers; lower layers don't know upper layers.
Companion systems — online for the long haul, responding the moment you speak — applications
are not carved out of this repo; they grow on top of it. They depend only on aicf-core.
aicf/harness nor aicf/infra imports any application —
application code is not in this repo.
One skill.yaml declares tools, prompts, and dependencies, plus plain Python. The
framework validates them before an agent sees them; install, enable, disable — no kernel code
changes.
- Skill / SkillRegistry
- SkillLoader
- SkillValidator
- CapabilityRegistry
aicf/harness/skills/yaml_loader.py /
yaml_manager.py); append a skill directory at runtime — no kernel changes.
Handles exactly "messages in, tools out": the turn loop, the tool protocol and registry, context assembly and trimming, memory, sessions and transcripts, pipelines and events. It knows no business.
- agent loop
- tools
- context assembly
- memory
- sessions
- pipeline / events
Handles only processes, HTTP, VRAM, disk, secrets, and budgets: model routing, the resource pool, storage, gateway, auth, policy. It knows no business semantics.
- model routing
- resource pool
- storage
- gateway
- auth
- policy
These subpackages also live in the two layers — every claim above can be pinned to one of them:
- aicf/harness/kernel/
- aicf/harness/agent/
- aicf/harness/skills/
- aicf/harness/memory/
- aicf/harness/voice/
- aicf/infra/runtime/
- aicf/infra/control/
- aicf/infra/resources/
- aicf/infra/eval/
Rule 1: dependencies point down
Cares about business → belongs in the aicf-ui repo; messages and tools → aicf/harness; only processes / HTTP / VRAM / disk / secrets → aicf/infra.
Rule 2: aicf/infra/eval and aicf/infra/runtime must not import aicf.harness
The eval layer only knows its own Trace / ToolCall; trace_from_events() does a read-only adaptation.
Rule 3: undecided ≠ pass
Without a baseline, the regression and cost gates are explicitly marked "undecided" — never a silent PASS.
Rule 4: applications grow on top, they are not carved out of it
This repo contains no application code: skill packs live outside (aicf/harness/skills/), products live in their own repos and depend only on aicf-core.
Documentation index
These are the maintainer documents under the repo's docs/. Links use relative paths
(../../architecture.md from this page) pointing at the Markdown sources in the repo;
once the site is deployed to GitHub Pages, they are rewritten automatically to the matching GitHub files.
| Document | What's inside | When to read it |
|---|---|---|
README.md |
Doc index: reading paths organized by "day one / before changing code / going deeper into a layer" | First time in this repo |
architecture.md |
The two layers and dependency direction, module map, request path, global singletons, quality baseline | Always read this one first |
security.md |
Security model: tool contracts, admission, approval, sandbox tiers, identity, audit | Before touching anything with side effects |
runtime.md |
Managed runtime: journal, checkpoint, idempotency, recovery | Before touching session state or recovery behavior |
evaluation.md |
The eval loop: dataset language, the four gates, run version, regression | Before touching anything that changes agent behavior |
harness.md |
Agent loop control flow and events, AgentSpec, tools, context trimming, hooks |
Before changing agent behavior |
infra.md |
Orchestrator layering, scheduler, providers, resource pool, policy, storage, finetune, device gate | Before changing models, resources, or storage |
skills.md |
The skill system: directory layout for declarative skills, loading, validation, capability injection | Writing a skill pack, or debugging "my skill isn't taking effect" |
skill-spec.md |
The public skill-pack spec (v1): field tables, three hard rules, version promises — the ecosystem's interface | Publishing a skill pack for others to use |
control-plane.md |
Control plane: agent identity, delegation authority, asset lifecycle, cost ledger | Wiring up multi-agent, or governing agent assets |
sdk_guide.md |
Embedding AICF into another project as a Python SDK | Hooking it into your own system |
configuration.md |
Configuration sources, key environment variables, precedence, credential handling | Changing config, or debugging config that isn't taking effect |
community.md |
Community channels, the path to a first contribution, the code of conduct | Asking questions or starting to contribute |
maintenance.md |
Placement rules, invariants, checklists by change location, repo hygiene | Before touching the code |
technical-debt.md |
Known technical debt by priority, verified defects, fix order | Planning the work |
roadmap_1.0.0-rc0.md |
The 1.0.0 workflow, acceptance criteria, current status, risks | Planning or reviewing 1.0.0 |
releases/v1.0.1.md |
v1.0.1 release notes: aicf init scaffold, the voice layer, memory provenance, resource profiles, the offline dataset |
Current release |
releases/v1.0.0rc3.md |
v1.0.0rc3 release notes: control plane, identity and delegation, audit trails, and more | Before upgrading to 1.0.0 |
Migrating to 1.0.0
As of 1.0.0 the top level no longer occupies the names harness and infra;
everything moves into the aicf namespace. The distribution name and the CLI entry point
are unchanged.
| Old (before 1.0.0) | New (1.0.0+) | |
|---|---|---|
from harness import create_agent, tool |
→ | from aicf.harness import create_agent, tool |
from harness.tools import ToolRegistry |
→ | from aicf.harness.tools import ToolRegistry |
from infra.models.base import IChatClient |
→ | from aicf.infra.models.base import IChatClient |
from infra.x import y |
→ | from aicf.infra.x import y |
One command finds every import that needs changing
grep -rn --include='*.py' \
-E '(^|\s)(from|import)\s+(harness|infra)\b' .
The top-level names are no longer occupied, so they cannot collide with a harness / infra from some other project.
Three names, deliberately different
- Distribution name (pip):
aicf-core - Import name (Python):
aicf.* - CLI entry point:
aicf
The distribution is not named aicf because that name on PyPI is too similar to this
project and the claim would be rejected; the import is not top-level harness /
infra because those two names already belong to someone else. Only the Python import
paths change — CLI arguments and config files are unaffected.
Repository: github.com/ccjjfdyqlhy/aicf-core
Run the walkthrough first
Install it, scaffold a project, read the tool catalog, get denied once, run the offline dataset, score it, ship the gate report. Ninety seconds is enough to know whether this is the thing you need.