Eve resolves two things for the active request: who is calling, and what they can touch.
Auth chain#
agent/channels/eve.ts tries three authenticators in order:
agataBetterAuthEveAuth— the real one. Cookie →GET /api/auth/get-session→ Eve principal.vercelOidc()— for internal invocations on Vercel.localDevWithoutCookie— only when there is no cookie. Deliberately does not mask a failed Better Auth attempt: if there was a cookie and it failed, the tools would see an empty principal.
The Better Auth authenticator:
- Reads the cookie and resolves the session over HTTP (it does not import Next
server-onlymodules). - Requires the
x-agata-profile-idheader. Without it, 403. - Verifies membership against
GET /api/profiles/:id/access. - Stamps only non-secret references and context onto the principal: the Better Auth session row id,
profileId,ianaTimeZone,email,name, andallowedSectionIds,sectionAdminIds,profileRole. The bearer token is never serialized into Eve state; tools resolve the current unexpired token immediately before each Go request.
The last three are what govern the gate.
The section gate#
Agata grants access by section to each member: daily, work, health, nutrition, finance, library, goals, agent.
Each file in agent/tools/ wraps its tools in sectionToolset:
If the member does not have the section, the resolver returns null and those tools do not exist on that model step: they never reach the prompt, and the model cannot attempt a call the API would reject with 403.
hasSection mirrors requireGoDomainServerAccess in the app exactly: an empty section list denies, and agent is always granted (that is why the platform toolset is always-on).
The gate is a precision and prompt-size improvement, not the security boundary. The Go API still authorizes each request separately. A gate failure would expose a tool name, never the data.
Delete approval#
Destructive tools use approveDeleteInSection(section), which mirrors canDeleteInProfileSection:
- If the caller cannot delete in that section →
deniedwith a reason the model can relay. - If they can →
user-approval: pause the turn and wait for a person.
It turns a confusing mid-conversation 403 into an explanation.
Per-member instructions#
agent/instructions/20-sections.ts reads the same active principal as the gate at turn.started and composes the prompt briefing: one block per granted section, plus a line naming the denied ones with the instruction to say "that section is not enabled for you" instead of "Agata does not have that".
A single source of truth: the prompt cannot describe a capability the tools do not have.
Refresh per step#
Tool resolvers run on step.started, while the section briefing refreshes on turn.started. Each model call rebuilds the catalog from the active principal's permissions, so a revocation is reflected on the next step and the next turn's prose cannot retain a stale grant.
When progressive routing is enabled, section access is applied before capability activation. Screen context can activate one relevant group and search_agent_tools can activate bounded additional groups for the current turn, but neither can grant a section or bypass the API. Bulk groups require an explicitly plural request. Activation state is reset at the next turn.started.
This scope also keeps the handler and approval policy associated with the same definition that announces the tool. Eve does serialize durable callback references for replay, so sectionToolset binds both live and durable callbacks to the catalog name: an identity mismatch is blocked before any write. The Go API remains the authorization boundary and re-checks every request.