Today current · the cycle
Verified from apis/lawrence-api and the agents repo. lawrence-api
(api) invokes the Python agent-gateway (a service); the agent's tools then call back up
into lawrence-api's /vfs. That up-arrow — a service reaching into an api — is both
the cycle and the layering break. It exists because the Python loop can't reuse lawrence-api's TS VFS
adapters, so it reaches back over HTTP.
/vfs) because the Python loop can't import
lawrence-api's TS VFS adapters. Rewriting the loop in TS removes the cause: a TS runtime imports the
shared @lawhive/content-framework and calls services down, like lawrence-api does.B-fit-1 — put the loop in the chat api recommended
The loop is api-tier orchestration, and lawrence-api already owns chat + VFS + the
AIThread model — so the loop belongs there. Tools become in-process calls through
@lawhive/content-framework + its service clients. The Python agent-gateway is
deleted; every edge points down the tiers.
/vfs hop, the KMS signing, and the
content-retrieval client layer, because tools call the shared framework as functions. The
long-lived chat workload is isolated by deploying the api as its own pool (a deploy choice, not a layering
one). Cost: the runtime lives in platform-v3 and shares the api's lifecycle.B-fit-2 — a sibling agent-runtime api if you want independence
For independent deploy/ownership, the runtime is its own api in apis/, beside
lawrence-api. It owns the AI thread model and builds its tools from the same @lawhive/content-framework
+ its own service clients — calling services directly, never lawrence-api. Triggers arrive as Inngest
events, the documented way services signal change.
Rejected — runtime as an api above lawrence-api
Stacking the runtime on top so it calls down into lawrence-api (app → agent-runtime
→ lawrence-api → services) is gateway-on-gateway: an api→api edge in the one direction
v3 keeps rare, and it puts the tool surface back behind another api — which is exactly the call-up
that reintroduces the cycle. The fix in both shapes above is the same: tools reach the
services tier through the shared @lawhive/content-framework, never back up into an api.
The rules that keep it acyclic
Calls only go down the tiers. app → api (orchestration) → service (domain). Never up.
The agent's tools reach the service tier via the shared content-framework — not back up into an api's /vfs. That up-call is today's whole cycle.
The chat api owns its state. AIThread, the durable stream, and auth live with whichever api runs the loop, so the runtime never reaches up for them.
Cross-domain triggers go over Inngest events, the documented service pattern — a service emits, the runtime wakes. No upward dependency, even for cap-05.