AIPF docs

AIPF architecture design

How the AIPF proof of concept is built: the parts, how a work item moves through them, how an agent session runs, how tool calls are checked, and where state lives. It describes the code in this repository as of 2026-10-22. For the leadership overview, see the leadership overview (in Vietnamese).

AIPF runs on more than one cloud. Most of it is shared: the agents, the workflow, the session runner, the tool policy, the state model, the console and the security model are the same code on every cloud. Each cloud adds a pack under providers/: the services the shared code runs on, and the adapters that connect them. Two packs are deployed: AWS (providers/aws/) and Cloudflare (providers/cloudflare/).

This document has three parts:

  • Sections 1 to 8, shared design: what holds on every cloud, in generic terms.
  • Sections 9 and 10, the packs: what is specific to AWS and to Cloudflare.
  • Section 11, comparison: the two packs side by side, with what phases 1 and 2 measured.

Status, 2026-10-22. Development is paused at this architecture. The POC's AWS resources were removed with providers/aws/aipf.sh down; aipf.sh up and aipf.sh build rebuild them from this repository. The Cloudflare pack runs end to end with its own knowledge base (phase 2), built on D1, Vectorize and Workers AI.

Each diagram has an interactive HTML version (pan, zoom, guided views, light and dark) in docs/architecture/diagrams/ and a static SVG in docs/architecture/svg/. build.sh rebuilds both from the JSON specs. The diagrams use generic names; sections 9 and 10 say what each part is on each cloud.

1. What it does

A Jira work item labelled aipf starts one run: one execution of the work item workflow. The run takes the work item through up to six agents, one per stage of the software life cycle:

Agent Stage Hands over (verdicts) Optional Sandbox Network
PM plan the story; ready, declined yes light internet
Designer design the design; ready yes light internet
Developer build a pull request; pr, no_pr, needs_human no full internet
Reviewer review pull request comments; approve, changes yes full internet
Tester test (UAT on staging) a report; pass, fail no light staging
Operator operate health and a release note; healthy, unhealthy yes light staging

A person approves and merges every pull request. The agents never merge.

registry/agents.json is the single source for the agents: the workflow's stages, each agent's identity and tool policy, the session runner and the console all read it. The agent CLI and the model are parameters of a run: Claude Code on a Claude subscription by default, OpenCode with an API model, or Pi.

2. System view

AIPF system architecture

Open the interactive version →

Everything runs in one cloud account and one region. The parts, by layer:

Layer Parts Code
People and channels Web console, Jira, Slack, Confluence console/, connectors/
Control plane The orchestrator's handlers; the work item state machine; one key-value table; the registry; the reconciler control-plane/, providers/aws/workflow.asl.json, registry/
Agent runtime One container per agent session, in a light class or a full class (with PostgreSQL for the repository's tests); an image with the repository and its dependencies installed; the session runner; one adapter per CLI harness/
Shared services The agent gateway: MCP, the policy check and the tool targets jira, codecommit (the repository, whichever it is), memory, confluence, slack, ops, vault; the knowledge base; upstream MCP servers; project memory in blobs gateway/, registry/tools.json, registry/mcp-servers.json
Delivery The sample repository, where a pull request into main needs one person's approval; build jobs for CI, the merge queue's branch update and the staging deploy (one at a time); staging with PostgreSQL 16 the pack's deploy code

{app} is the environment's APP setting, the prefix of every resource name.

Ports and adapters

The control plane and the agents' tools reach the cloud only through platform/ and the external systems only through connectors/. AIPF_CLOUD picks the cloud adapter: aws, cloudflare, gcp (unit-tested, not deployed) or memory (tests). A new cloud is a new adapter behind these seven ports, plus a pack that runs the containers and the workflow.

Port Contract (short) AWS Cloudflare
store conditional put, update, remove; query, queryIndex DynamoDB, one table D1, one items table; conditional writes compare and swap the row's ver
blobs versioned get, read, put, list S3, one versioned bucket R2, one bucket; memory versions copied under .versions/
settings the settings object Secrets Manager the AIPF_SETTINGS Worker secret
workflow start, succeed, fail, status, stop Step Functions task tokens the same state machine in a Cloudflare Workflow; tokens in the tokens table
sandbox stop a run's session tasks ECS the run's session containers, stopped through their Durable Objects
ci failure log, last deploy CodeBuild, CloudWatch Logs the builder's log in R2 and its result
ops staging status, logs, deployment, test fixtures ECS, RDS, CloudWatch Logs the staging supervisor in the staging container

Connectors have one contract per kind: tracker (Jira), chat (Slack, an incoming webhook, or none), docs (Confluence) and repository (CodeCommit, GitHub), over one HTTP helper with time limits and retries. See platform/README.md and connectors/README.md in the repository.

3. The workflow

Work item workflow

Open the interactive version →

providers/aws/workflow.asl.json defines one execution per run, 86 states, in Amazon States Language. Both packs run this same file: Step Functions on AWS, an interpreter inside a Cloudflare Workflow on Cloudflare. The main path:

  1. StartRun takes the work item's lock (ISSUE#<key> / ACTIVE) with a conditional write. A second start on the same item ends at once as duplicate.
  2. Pm, Designer, Developer: each starts a session container and waits for its task token, then an orchestrator step (AfterPm, …) judges the session from what is in the repository, Jira and the run state, not from the agent's word.
  3. Checks is a Parallel state with two branches: CI then the image build, and the Reviewer agent.
  4. RequestApproval waits on a task token for up to 7 days. The console or a merge event from the repository ends the wait.
  5. Merge queue: TakeQueue (wait 30 s and retry while another run holds it), UpdateBranch (a build job), MergedCI and MergedImage on the updated branch, then Merge by fast-forward.
  6. Staging lease (TakeLease, wait 30 s), then DeployStaging (a build job).
  7. Tester. On fail, TesterDecision asks a person for up to 24 hours: accept, fix or revert. A revert merges a revert pull request through the merge queue, then Redeploy deploys main again.
  8. Operator, then Done: Jira moves to Done and Slack gets the result.

A failed check, deploy or test goes to AttemptsLeft, which sends the developer agent back for another round from main through a new pull request. A run escalates to a person after 3 failures (MAX_FAILURES) or 8 developer rounds (MAX_ROUNDS). AskHuman waits up to 3 days for an answer to an agent's question.

Run outcomes. done, declined, closed, wont_do, duplicate, reverted, stopped, escalated, failed and timed_out; only the last three count as failures.

Timeouts and retries

The state machine sets these, so they are the same on both clouds.

Step kind Timeout Retry
Orchestrator step default service errors 8 times (2 s doubling, up to 60 s, jitter), then once on any error; then the run escalates with the step's name
Agent session 40 min (developer 60 min), heartbeat 300 s 3 times on container service errors
Build job 60 min 10 times on account limits, 60 s apart
Waits for a person approval 7 days, question 3 days, tester decision 24 h none

Keeping runs consistent

  • Locks and answers are conditional writes. A run releases only its own lock; an answer is taken once, and a late answer is kept with the run and the person is told.
  • An execution that ends badly (failed, timed out, stopped outside the console) reaches the orchestrator as an event; it closes the run, releases the lock and the approval, and says so in Slack.
  • Lost events are kept and shown in the console, and can be sent again; the orchestrator ignores what is already decided.
  • The reconciler runs every 5 minutes and does what a missed event would have done: resume a run whose pull request was merged or closed, end a run whose execution stopped, release a stale lock.
  • Pause stops new runs from every entry point while running runs go on.

Sections 9 and 10 say how each cloud delivers these events and keeps the lost ones.

4. An agent session

One agent session

Open the interactive version →

harness/runner/session.mjs run is the container's entry point on both clouds. It:

  1. Reads the run item and the handoff of earlier agents (ARTIFACT#<agent>) from the run state.
  2. Prepares the workspace from the image: the repository at the run's branch agent/<KEY> (or main), with dependencies already installed, and the services named in the repository's .aipf/environment.yaml.
  3. Takes an identity scoped to the session (<agent>-<run>-<attempt>): it may push only the run's branch, and it may not end a workflow step other than its own.
  4. Composes the prompt: registry/roles/_common.md, the role file, the task, the handoff, up to 20 amendments, up to 5 earlier runs of the same work item, the reviewer's checklist counts, then feedback from failed checks.
  5. Starts the agent CLI as the unprivileged user agent, which cannot read the runner's environment. MCP goes to the agent gateway, which knows the agent and the run from the session's identity, never from the agent.
  6. Sends a heartbeat every minute from a worker thread.
  7. Writes the record through the redactor: the transcript and events to blobs transcripts/<run>/<agent>-<attempt>/, the measures to the table as SESSION#<agent>#<attempt> (duration, setup time, turns, tokens, the CLI's cost estimate, tool calls, tool errors, refusals, git result), and one log line.
  8. Sends the task token. The runner reports success whatever the agent did; the next orchestrator step decides what happened. If the runner cannot record the session, it fails the step itself (SessionFailed).

Adapters in harness/runner/adapters/ (claude-code.mjs, opencode.mjs, pi.mjs) translate the same role, prompt and tool list into each CLI's flags and configuration.

5. Tool calls and the agent gateway

One agent tool call

Open the interactive version →

  • Identity. Each agent has its own identity. The platform sets the agent and run arguments of every platform tool call from the session's identity and hides them from the agent's tool list.
  • Policy. The rules come from registry/agents.json. Each agent may call only its own tools, and only when the agent argument names the caller. Some tools carry a condition on their input, for example the developer may move a Jira item only to In Review, and may open pull requests only from agent/* branches. The knowledge base and upstream MCP servers take no agent argument, so the caller's identity alone decides.
  • Tools. One handler, gateway/tools.mjs, serves the platform tools on both clouds. Tools sign what they post with the agent's name (for example [AIPF Designer agent]) and refuse calls for a run that has ended.
  • Vault. API keys live in the cloud's secret store. vault___list shows the credentials an agent may use; vault___fetch makes an HTTPS request with the key added to one header, only for that credential's agents, hosts, paths and methods, and removes the key and its encodings from the response. registry/vault.json lists the rules, never a value.
  • Refusals come back as tool errors that say "denied by the AIPF policy", and the runner counts them per session.

6. State and data

One key-value table, keyed pk / sk, with the same keys on every cloud:

pk sk What
RUN#<runId> RUN the run: work item, agents, models, status, stage, attempts, pull request, times, earlier runs
SESSION#<agent>#<attempt> one agent session's measures
ARTIFACT#<agent> an agent's handoff (story, design)
ISSUE#<key> ACTIVE the work item's lock
APPROVAL the pull request waiting for a person, with its task token
Q#<time> a question an agent asked
HUMAN#<id> HUMAN one question or approval link, answered once
AGENT#<id> CONFIG console settings of an agent (on or off, model)
PLATFORM engines, PAUSE, RECONCILER, … platform switches and the reconciler's last run
AUDIT one item per action admin actions from the console and aipf.sh, with the state before and after

Sparse indexes: run-index (runs by date), issue-index (runs by work item) and open-index (open questions and approvals).

Blobs (one bucket, memory versions kept): memory/ (project memory notes), memory-proposals/ (agent proposals waiting for a person) and transcripts/<run>/<agent>-<attempt>/. The secret store holds the settings, the Claude token and the vault's keys. The container registry holds the images.

Project memory. Every agent reads the notes; agents only propose changes. A person accepts, edits or rejects each proposal in the console; a proposal whose note changed since the agent read it is marked stale; Accept applies it when it still applies cleanly, and otherwise opens the editor with the conflict marked.

7. The console

The console is the same code on both clouds (console/), behind a cloud port with one contract. Sign-in needs an email, a password and a TOTP code (MFA required).

View What it shows
Mission control what needs a person, live runs, key numbers, staging, latest activity
Inbox pull requests waiting for review and agents' questions, with a reply box
Runs search, start (agents and models), stop; a run's page with the stage stepper, the pull request review with line diffs, timelines, sessions with logs, handoffs and the workflow trace
Insights success rate, first pass, rework, lead time, cost per done run, retries by reason, per-agent and per-model figures
Agents perspective, verdicts, tools with policy conditions, sandbox, role, instructions; turn optional agents on or off, choose models
Memory proposals as diffs, note history and search
Knowledge a chat over the knowledge base with sources
Platform region, connections, policy mode, engines, models, staging, lost events, reconciler, pause, merge queue, audit trail

Three roles: viewer reads; operator also runs, reviews, merges, answers and works staging; admin also changes agents, memory and the platform.

8. Security controls

  • One identity per agent, and a policy per agent and tool, checked on every call.
  • Sessions push only to agent/* branches, and each one only to its own run's branch.
  • Pull requests into main need one approval from a person; only the merge queue or a person merges.
  • API keys stay in the vault and never reach the agent, its transcript or the logs.
  • Sandboxes have no inbound access.
  • Staging has no public entry. Only the tester and operator sessions reach it, and it holds synthetic data only.
  • Transcripts and session records pass through a redactor.
  • Every admin action is in the audit trail; every tool call and policy decision is logged.
  • The orchestrator can be paused or stopped at once.

9. On AWS

providers/aws/. Everything runs in one AWS account and one Region.

Part AWS service
Orchestrator and its steps Lambda; Step Functions state machine {app}-work-item (STANDARD, JSONata)
Run state DynamoDB table {app}; S3, one versioned bucket (earlier memory versions kept 90 days)
Agent sessions ECS Fargate ARM64 task definitions {app}-session (2 vCPU, 4 GB, with a database sidecar for the repository's tests) and {app}-light (1 vCPU, 2 GB); a snapshot image per main commit, built by CodeBuild with a SOCI index
Agent gateway AgentCore Gateway (AWS_IAM) with Lambda targets; AgentCore Policy with Cedar policies; the vault in AgentCore Identity
Knowledge base Bedrock Knowledge Base (Retrieve), managed outside this repository; upstream MCP servers (AWS Knowledge)
Repository and builds CodeCommit repository {app}-sample with an approval rule (one approval); CodeBuild projects for CI, the merge-queue branch update and the staging deploy (concurrency 1)
Staging ECS service staging and RDS PostgreSQL 16
Console One Lambda function behind an API Gateway JWT authorizer; Cognito sign-in with TOTP; refresh tokens last 12 hours; roles from Cognito groups
Secrets and images Secrets Manager; ECR
Events EventBridge rules and schedules; SQS for lost events
Logs and cost CloudWatch Logs; Cost Explorer by the Project cost tag, whose value is {app}

Agent sessions. Each stage is an ECS RunTask with waitForTaskToken. The runner assumes its task role again with a session name <agent>-<run>-<attempt> and a session policy that denies writing any Git reference but the run's branch, assuming a role, and ending a workflow step. It serves these credentials on a Unix socket; the agent's AWS configuration reads them through creds.mjs as a credential_process. MCP goes through the identity filter (harness/runner/mcp-identity.mjs) and mcp-proxy-for-aws to the agent gateway, signed with SigV4. Sandboxes allow outgoing HTTPS only, and there is no NAT gateway.

Agent gateway. Each agent has its own IAM role, {app}-<agent>. gateway/policies.mjs generates the Cedar policies from registry/agents.json; a call is allowed only when the agent argument names the IAM role that signed it. One Lambda function, gateway/tools.mjs, serves the targets jira, codecommit, memory, confluence, slack, ops and vault.

User gateway (AIPF MCP). A second AgentCore Gateway, {app}-harness, lets a person's chat client (for example Claude Code) start and follow runs. It uses CUSTOM_JWT with Cognito access tokens from the console's user pool, same users and MFA. A request interceptor puts the signed-in user in every call, applies the console roles, writes an audit line (user, tool, argument names) and redacts results. It exposes 11 harness tools (agents, start, list, get, trace, transcript, log, stop, MCP servers, vault, platform), the knowledge base and the same upstream MCP servers the agents have. Some names still say harness, the platform's earlier name.

Events. An EventBridge rule catches an execution that ends badly, and CodeCommit pull request events resume runs. Lost events (failed async invocations, events dropped while the orchestrator is stopped, undelivered rule targets) go to an SQS queue for 14 days, with two CloudWatch alarms; aipf.sh events replay sends them again. Reserved concurrency 0 on the orchestrator is the emergency stop; its events wait in the lost-events queue.

Where to look.

What Where
Agent sessions DynamoDB SESSION#…, S3 transcripts, /<app>/sessions; aipf.sh sessions --csv
Workflow Step Functions history and /aws/vendedlogs/states/<app>-work-item
Tool calls and policy decisions the gateway's vended log group and /aws/lambda/<app>-tools; aipf.sh decisions
CI, snapshot, deploy, staging /<app>/ci, /<app>/snapshot, /<app>/deploy, /<app>/staging
Console and AIPF MCP /aws/lambda/<app>-console, -interceptor, -harness
AWS cost Cost Explorer by the Project tag; aipf.sh cost

Logs are kept 30 days.

Deploy, run, remove.

Command What
providers/aws/aipf.sh up the CloudFormation stack, the sample repository, the approval rule, memory, both gateways, policies
providers/aws/aipf.sh build the harness image, then the session snapshot of main
providers/aws/aipf.sh run KEY [engine] [model] [agents] one run
providers/aws/aipf.sh down removes everything above; the knowledge base is not touched

10. On Cloudflare

providers/cloudflare/. One Worker, two Cloudflare Workflows, D1, R2, Vectorize, Workers AI and four container classes take the place of the AWS services. The shared handlers run unchanged inside the Worker, on events shaped like API Gateway's. The pack's README has the full mapping, the layout and the runbook.

Part Cloudflare service
Orchestrator and its steps The Worker; the same state machine interpreted inside a Workflow instance (WorkItem, src/asl.mjs): every side effect is a durable step, with Retry and Catch as the state machine defines them, and a Step Functions shaped history for the console's trace
Task tokens The D1 tokens table; a step waits for the Workflow event of its token, and the first close of the row wins
Run state D1 items (the same keys; sparse indexes are JSON fields); R2, one bucket
Agent sessions SessionLight (standard-2) and SessionFull (standard-3) containers, one Durable Object per task; one image for every class, with the repository and its dependencies as of the last deploy
Agent gateway The MCP server in the Worker (src/mcp.mjs): the agent's own tools, the registry's conditions, the vault; the vault's keys are Worker secrets VAULT_<NAME>
Repository and builds GitHub, through the Worker's git proxy with the platform's token; Builder containers (standard-3) run the jobs ci, image, deploy and update-branch, with the same result shape as CodeBuild's
Staging One Staging container (standard-1): a supervisor, PostgreSQL 16 and the app, with no internet
Console The Worker serves the page and the API; its own sign-in (the users table, PBKDF2 passwords, TOTP) issues an ID token with Cognito's claims that lasts an hour; the review uses GitHub's pull requests, reviews and commit statuses
Secrets and images Worker secrets (AIPF_SETTINGS, the vault); the account's container registry
Events GitHub's webhook and the D1 outbox table, drained by a cron every minute; the reconciler on the cron every five minutes
Knowledge base A Markdown mirror of Confluence and SharePoint, kept by the KbSync workflow (src/kb-sync.mjs) every six hours: documents converted by Workers AI toMarkdown, cut into passages along the headings, in D1 (kb_docs, kb_chunks, FTS5 kb_fts), R2 and Vectorize (bge-m3, 1024 dimensions). The agents' kb target (src/kb.mjs): kb___Retrieve, a hybrid search fused by rank; kb___read, a whole document; kb___grep, the lines that hold a text
Logs and cost Workers Logs; build and runner logs in R2; the account's GraphQL analytics, priced by aipf.sh cost

How containers reach the platform. A container never holds a cloud credential or the GitHub token. It reaches the platform only through four hosts that the Worker answers itself (src/outbound.mjs):

Host What Classes that may call it
control.aipf the control API: run state, blobs under the session's own prefix, step success and failure, heartbeats; each container has an HMAC key of its own task, and each class its own scope all
git.aipf the git proxy: fetch, and push only to the container's own branch sessions, builder
mcp.aipf the agent gateway sessions
staging.aipf the staging app sessions, builder

Any other host is the internet (Claude's API, the npm registry). The staging container has no internet.

Agent sessions. The Workflow step starts a container through its Durable Object and waits on its token. The runner talks HTTP to the control API instead of an SDK, and its scoped identity is the container's row in the D1 containers table: the row names the agent and the run, and the Worker reads it on every call, so the agent never says who it is. The gateway refuses a builder, the staging supervisor and a stopped session. A container that stops before it ever calls the Worker (the container_calls table) is started once more in a new task for the same step, as ECS and CodeBuild retry their own provisioning. A session that ends without its record keeps the end of its runner's log, redacted, as entry.log next to its transcript.

Events. An execution that ends badly, a pull request event and the CLI's actions go through the outbox table, which the cron drains every minute with retries. An event that runs out of tries is shown as a lost event in the console, where it can be replayed. A Worker that restarts replays the Workflow instance from its cached step results.

Where to look.

What Where
Agent sessions D1 items (SESSION#…); transcript and runner log in R2 transcripts/<run>/<role>-<attempt>/; aipf.sh sessions
Workflow D1 executions and history; the console's trace; aipf.sh status
Containers D1 containers and container_calls; aipf.sh status
Builds R2 builds/<task>/log.txt; the console's run page
Tool calls, refusals, git pushes, sign-ins, console actions Workers Logs, one JSON line each, no argument values; aipf.sh logs (masked)
Cloudflare cost aipf.sh cost [FROM] [TO]: usage by product at list prices, with the containers' time by class

Deploy, run, remove.

Command What
providers/cloudflare/aipf.sh up D1, R2, the schema, secrets, the GitHub repository, the Worker and its containers, the webhooks
providers/cloudflare/aipf.sh token the Claude token as a Worker secret
providers/cloudflare/aipf.sh console-user create EMAIL --group admin --out FILE a console user; the password and the TOTP secret go only to the file
providers/cloudflare/aipf.sh run KEY [engine] [model] [agents] one run
providers/cloudflare/aipf.sh kb sync [--force], kb status a knowledge base sync now (the cron runs one every six hours); its documents and last syncs
providers/cloudflare/aipf.sh deploy after a change: the Worker's files, the image, the Worker and its containers
providers/cloudflare/aipf.sh down removes everything up created; the GitHub repository stays

11. Comparison

The same part on each cloud

Part AWS Cloudflare
Workflow engine Step Functions the same state machine in a Cloudflare Workflow
Task tokens Step Functions task tokens D1 tokens table
Orchestrator, console API, tools Lambda functions one Worker
Key-value table DynamoDB D1
Blobs S3 (versioned) R2 (versions copied under .versions/)
Secrets Secrets Manager Worker secrets
Session containers ECS Fargate ARM64 tasks Containers, one Durable Object per task
Session identity IAM task role and a scoped STS session the container's row and a per-task key for the control API
Agent gateway and policy AgentCore Gateway with Cedar policies the MCP server in the Worker, with the registry's rules
Vault AgentCore Identity Worker secrets VAULT_<NAME>
Repository CodeCommit GitHub through the Worker's git proxy
Build jobs CodeBuild Builder containers
Staging ECS service and RDS PostgreSQL one staging container with its own PostgreSQL
Sign-in Cognito the Worker's sign-in
Events and schedules EventBridge, SQS GitHub webhook, D1 outbox, cron
Logs CloudWatch Logs Workers Logs, R2
Knowledge base Bedrock Knowledge Base (managed parser, chunking and reranker), kb___Retrieve a Markdown mirror in D1, R2 and Vectorize, kb___Retrieve, kb___read and kb___grep
Chat client gateway (AIPF MCP) AgentCore Gateway with a request interceptor not built

What phase 1 measured

The same test set ran on both packs, with Claude Code on Sonnet 5.5. The agents' work was of the same quality on both, and a done run used about the same number of sessions. Times are medians; the Cloudflare figures are from 2026-10-20 to 2026-10-22, the AWS figures from round 4 and its re-checks.

Measure AWS Cloudflare
Done run, without the person's waits 17 min 25 s (10 to 11 min without rework) 8 min 7 s (6 to 7 min without rework)
Platform overhead per agent step (step time minus the agent's time) 25.7 s 16.3 s
Container start about 20 s of provisioning and image pull first call to the Worker after 2.5 s (light), 5.3 s (full)
CI build 35.5 s 17 s
Image build 42 s 12 s
Deploy to staging 114.5 s 16 s
Sessions and agent cost per done run 8.3 sessions, $1.20 7.0 sessions, $0.84
Cloud cost while idle about $1 a day (RDS, the staging task, VPC endpoints, Secrets Manager) about $0: containers bill only while they run; Workers Paid is $5 a month for the account
Cloud cost of the runs $4.74 for a day of runs, with CodeCommit's and Route 53's monthly charges in it $0.22 at list prices for 114 containers over three days, before the monthly allowance

The agent cost is the CLI's estimate at API list prices; on the Claude subscription it is a flat fee. The AWS figures include the knowledge base, which costs $0.03 to $0.07 a day.

What phase 2 measured

Phase 2 gave the Cloudflare pack its own knowledge base from the same Confluence and SharePoint sources. The benchmark in docs/kb-benchmark.md and two work items measured it, with Claude Code on Sonnet 5.5, on 2026-10-22.

Measure AWS (Bedrock knowledge base) Cloudflare (Markdown mirror)
Questions, 28 × 2 56/56, $0.048 a question 56/56, $0.028 a question
Work items, 6 × 2 64/64, $0.132 a work item 64/64, $0.081 a work item
Passages returned by a search 8 6, at most 3 from one document
Whole document, exact text no kb___read, kb___grep
Sync of the POC's sources managed ingestion job 655 s for 232 documents and 447 passages
Cloud cost $0.03 to $0.07 a day, plus $1 per 1,000 searches within the Workers Paid allowance; the first sync's embeddings $0.0013

End to end, a warranty work item whose values exist only in the documents ended done with all eight values right and cited, and a work item that asked for a rule no document sets ended declined after the PM asked a person. All nine sessions searched the knowledge base. The done run took 8 minutes without the person's waits and $0.98 of agent cost, against 8 minutes and $0.84 per done run in phase 1.

Other differences

  • Knowledge base. The AWS pack uses a Bedrock knowledge base, managed outside this repository, with one tool, kb___Retrieve, that returns eight passages. The Cloudflare pack builds its own from the same sources, in this repository: a Markdown mirror that keeps the Vietnamese diacritics, a hybrid search that returns six passages, and two more tools, kb___read for a whole document and kb___grep for an exact text, whose empty result means the documents do not say. A deployment without the knowledge base's sources leaves the kb___* tools out (AIPF_TOOLS_ABSENT=kb).
  • Repository. CodeCommit on AWS, GitHub on Cloudflare. The console's review uses each one's pull requests; on GitHub the approval is a commit status and the merge goes through the merge queue.
  • Session image. AWS builds a snapshot image for every main commit. Cloudflare builds one image at deploy, and each session fetches its branch through the git proxy.
  • Staging data. On AWS, staging's PostgreSQL is RDS and outlives a deploy. On Cloudflare, it lives in the staging container; a new container deploys the recorded release again. The staging container sleeps after 30 minutes without requests.
  • Concurrency. ECS and CodeBuild scale to the account's limits. Cloudflare limits containers per class in wrangler.jsonc: 4 light sessions, 3 full sessions, 3 builds and 1 staging at a time.
  • Policy engine. AWS evaluates Cedar policies generated from the registry. Cloudflare checks the same registry rules in the Worker; a condition its evaluator does not know denies the call.
  • Operations. The AWS pack is a CloudFormation stack plus scripts. The Cloudflare pack is one wrangler.jsonc and a D1 schema, deployed by aipf.sh; there is no network to configure.

Adding another cloud

A new cloud needs an adapter behind the seven ports (platform/), a way to run the state machine with task tokens, containers for the sessions and the builds, a secret store, and a gateway that checks the registry's rules for every tool call. providers/gcp/platform.mjs is such an adapter for Google Cloud, unit-tested and not deployed.

12. Known differences between docs and code

  • The workflow has 86 states; older notes say about 60.
  • The platform has seven ports (sandbox was added); some notes say six.
  • declined from the PM agent ends the run without building.
  • Some AWS names stay in shared code and data: the state machine is in providers/aws/, and the Cloudflare pack keeps Step Functions shaped histories and Cognito shaped ID tokens so the shared code does not change.