Infera
Agent harness for a product-team workspace
Built with Ajay Kannan Sekar. I wrote the agent service, the assistant panel and the skills.
- Team project (2 people)
- Python
- FastAPI
- Postgres
- React
Overview
Infera's agent harness is the loop behind the assistant in a product-team workspace: Python 3.12 and FastAPI, with its own agent loop and no agent framework.
It plans from skills, fans out to bounded sub-agents, and quarantines everything that comes from the web. The product manager stays in charge of changes: the run's own edit lands as a version they can undo, and edits to other documents or to project memory wait as diffs they accept or reject.
How it works
One turn of the agent
A request from the assistant panel is classified, planned from a skill, run step by step and checked before anything is written.
01 Classify
A request arrives from the assistant panel. Rules pick the path first; a classifier model decides only when the rules are unsure, and an unsure answer goes to the full path.02 Choose a path
The fast path is one tool loop on the main model with at most 3 tool calls. If it turns out to need a skill, the turn moves to the full path. This pass takes the full path.03 Understand and plan
One main-model call reads the request and selects skills. The plan is built from the selected skill's default steps.04 Run the plan
Ready read steps run up to 4 at a time. The run is checkpointed after each step, so a restarted service resumes it.05 Check and write
The draft gets deterministic number and citation checks, then lands in the document as a version the PM can undo. Knock-on edits and memory changes wait for the PM.
Skills and sub-agents
The main agent selects a skill from an index in the cached prompt and hands bounded tasks to sub-agents, which return a compact result rather than their transcript.
01 Cached prompt
Tools, the system prompt, project memory and the index of 53 skills sit in the cached part of the prompt, which takes up to 4 cache points; the request goes after it.02 Select and dispatch
The main model selects skills from the index (at most 2; one runs, the other is offered as a follow-up). The selected skill's body travels with each sub-agent's task.03 Fan out
Each sub-agent runs its own tool loop with its own tools and model role, at depth 1. Researchers take one topic each, up to 4 at once; section writers draft up to 4 sections at once.04 Return
A researcher, librarian or analyst returns a compact result of about 2k tokens, never its transcript. A section writer returns its drafted section.
When a model call fails
A retryable error is retried, then the call moves down a ladder of models across providers; the failure shown here is illustrative, the ladder is real.
01 The ladder
Each tier has a fallback ladder across providers; this is the main tier's. Under the Balanced preset, models priced above 1.5× its output price are moved to the end.02 Retryable error
The first model returns a retryable error: a 5xx, an overload or a timeout. The failure in this pass is illustrative; the ladder is real.03 Two retries
The call is retried twice with backoff. Both fail, so it moves down a rung.04 Next rung
The next model answers. An auth or out-of-credit error would instead put that provider out for 300 s.05 Breaker
Across calls, 5 failures in a row open a provider's circuit breaker for 30 s and its models are tried last. Once text has streamed there is no fallback: the failure is reported.
Web text and reviewed writes
Web pages are reduced to quoted facts before anything reaches the main agent, and the agent's writes come back to the product manager to undo, accept or reject.
01 Web pages
A researcher's searches and page reads come back as raw web text: at most 6 searches and 3 pages per topic. Raw text never reaches the main agent.02 Quarantine
A cheap model reduces each page to short facts with exact quotes, and a quote must appear in its page. An item that addresses an AI is dropped and counted, never summarised.03 Compact result
Only quoted facts reach the researcher, and only its compact, cited result reaches the main agent.04 Writes
The run's own edit lands as a version the PM can undo, after a check that asks first if it could show readers a source they can't open. Knock-on edits to other documents and memory changes are diffs the PM accepts or rejects.
One real run of the competitor-research skill, shown step by step as the assistant panel listed it.
3:37 · 6 topics · 136 sources · 80.3 credits
- 01Find what the project already knows
- 02Set the questions and competitors
- 03Research what the project doesn't know
- 04Compare and write the findings
- 05Check citations
- 06Send for review
What this doesn't cover
- The repository is private, so there is no code to link to.
- No cost saving is claimed for routing, caching or fallbacks, because none was measured.
- One stored LLM-judged scorecard for the compare-competitors case scored 0.29, and other runs of the same case score differently, so quality there is weak and not yet stable.
- The editor, the sync engine and the workers are Ajay Kannan Sekar’s work and are not described here.