# Main initial prompt audit

Audited against `demi_ai` `main` at `9ef2aeb8372420516934491b6a28c15ce917679e` on 2026-09-11.

Scope: the first model request for a Main turn. Tool results fetched after the model starts are excluded. Prior-turn tool results may still be replayed as conversation history.

## Verdict

The first request represents general capability mostly as eager content. A better general-purpose agent needs a compact operating model, a map of available context and capabilities, and reliable primitives for acquiring detail after it reads the request.

- Fixed instructions, the static skill catalog, and tool schemas total about **193,028 characters**, roughly **48.3k tokens**, before personal context, current state, integrations, the user request, or conversation history.
- Main exposes **42 full tool schemas totaling 111,722 serialized characters**, roughly **27.9k tokens**, on every ordinary non-code turn.
- Progressive disclosure exists through `load_tool_group`, but every non-routine Main session initially activates all five optional groups: documents, messaging, Mac-local, web, and sandbox.
- The response contract is stated in three overlapping layers, consuming about **8.9k characters** before additional visibility guidance repeats parts of it.
- The memory snapshot inlines three unbounded core files, up to three unbounded people files, and a full repository tree. These sources may matter, but their full payload is the wrong discovery mechanism.
- When a meeting is attached, deep meeting context can be appended through two paths. Each transcript copy can contain 40k characters.
- User-role turn injections persist in history, so time blocks, Work Index deltas, meeting blocks, and prior tool results accumulate until compaction.

Across 258 first model calls in recent development usage, the minimum input was **27,584 tokens**, median **96,096**, p90 **172,158**, and maximum **212,016**. **152 calls, or 58.9%, were at least 82k tokens.** These are development records, not a verified staging trace. Raw prompt text is intentionally not stored in PostHog; telemetry stores per-source token counts.

## General-purpose relevance scale

| Rating | Meaning |
| ---: | --- |
| 5 | Foundational to solving arbitrary requests and must remain available every turn |
| 4 | Essential capability, but usually as compact discovery metadata or an acquisition primitive |
| 3 | Useful when the surface or request selects it |
| 2 | Domain-specific detail that should load on demand |
| 1 | Runtime or rendering detail better enforced structurally |
| 0 | Duplicate or stale material that should be removed |

Relevance does not imply eager inclusion. A capability can rate 4 or 5 while its full schema or data payload belongs behind a loader.

## 1. Fixed instructions

Character counts are exact source-string lengths. Token estimates use characters divided by four and are directional.

| Segment | Chars | General-purpose relevance | Correct representation |
| --- | ---: | ---: | --- |
| Eve tool-execution rule | 273 | 3 | One compact rule available when the agent chooses tools |
| Soul: identity and judgment | part of 4,989 | 5 | Small stable operating identity, evidence discipline, and intent orientation |
| Soul: vibe and conversational style | part of 4,989 | 3 | Compact defaults; detailed style should not dominate reasoning |
| Main visibility contract | 1,619 | 2 | Enforce in the renderer; expose only semantic output choices |
| Main `work_routing` | 6,257 | 4 | Keep the general delegation model; load domain procedures as needed |
| Main `task_state` | 3,960 | 3 | Advertise tasks as an authoritative source; load task semantics with that source |
| Main `main_context` | 1,992 | 3 | Keep attachment and surface-scoping rules compact |
| Main `home` | 2,254 | 2 | Load with Home capabilities |
| Main trailing rules | 1,012 | 2 | Deduplicate into the core or local capability policy |
| Durable memory policy | 4,619 | 4 | Keep memory principles; enforce repository mutation and provenance outside the prompt |
| Operating `first_response` | 617 | 3 | Compact behavior for tool-led turns |
| Operating `security` | 629 | 5 | Stable trust boundary plus backend enforcement |
| Operating `approval_policy` | 5,128 | 5 | Compact invariant always; exact approval procedures beside action tools |
| Operating `runtime_tools` | 4,871 | 4 | Replace prose with a capability manifest and loaders |
| Operating `evidence_policy` | 3,595 | 5 | Core acquisition rule: choose authority, verify, and do not convert a failed read into absence |
| Operating `keyword_search_policy` | 2,015 | 3 | Load with search capability or express as a short widening rule |
| Operating `slack_context_policy` | 1,828 | 2 | Load with Slack context |
| Operating `slack_formatting` | 1,511 | 1 | Enforce through the Slack output adapter |
| Operating `clarification_policy` | 867 | 4 | Stable decision rule for ambiguity versus reasonable assumptions |
| Operating `requester_boundary` | 431 | 5 | Stable identity and authorization boundary |
| Operating `workflow_policy` | 1,523 | 2 | Load with workflow tools |
| Operating `workspace_files` | 424 | 3 | Compact source rule; detailed file behavior beside file tools |
| Operating `final_response` | 3,072 | 2 | Collapse into one structural output contract |
| Operating `message_draft_policy` | 2,769 | 2 | Load with messaging tools and enforce draft/send state in code |
| Shared `response_format` | 2,459 | 2 | Replace with a provider schema or one concise instruction |
| Shared `identifier_hygiene` | 773 | 4 | Stable rule preventing internal identifiers from leaking |
| Main `main_output_blocks` | 3,944 | 1 | Renderer-owned contract, not general reasoning context |
| Concise-reply reminder | 300 | 1 | Structural enforcement preferred |
| Main output reminder | 1,390 | 0 | Duplicates the output-block contract |
| Static available-skills catalog | 14,950 | 4 | Keep discoverability, but replace the flat list with compact categories and on-demand inspection |
| Conditional code-mode instructions | 1,251 | 3 | Attach only in code mode |

Fixed instructions plus the static skill catalog total about **81.3k characters**, roughly **20.3k tokens**. The high-value general rules are distributed across large domain blocks and repeated response contracts. They should be normalized into a small core and capability-local instruction bundles.

## 2. Session-start context

| Segment | Size | General-purpose relevance | Correct representation |
| --- | ---: | ---: | --- |
| Requester identity block | Variable | 5 | Always include a compact authenticated identity and boundary |
| `identity.md` | Unbounded | 4 | Small stable profile plus on-demand source handle |
| `priorities.md` | Unbounded | 4 | Compact current priorities; fetch detail when ranking or planning |
| `writing-style.md` | Unbounded | 3 | Load for drafting or user-facing composition |
| Matched `people/*.md` files | Up to 3, unbounded | 3 | Advertise people memory; retrieve only matched records |
| Full context repository tree | Variable, unbounded | 4 | Replace full tree with namespace summaries and search |
| Available integrations catalog | Variable | 5 | Compact capability discovery is foundational; operation schemas are on demand |
| User skills manifest | Variable | 4 | Compact categories, descriptions, and loader handles |
| Eve workspace overview and root entries | Variable, conditional | 3 | Include only for workspace surfaces or expose through inspection |
| Lane-rotation recent-context summary | Variable, conditional | 4 | Bounded checkpoint for continuity, never a substitute for authoritative state |

## 3. Turn-start context and history

| Segment | Size | General-purpose relevance | Correct representation |
| --- | ---: | ---: | --- |
| Current-time and 14-day weekday block | about 1,996 chars | 4 | Replace with compact structured time and locale metadata |
| Work Index wrapper and rows | Up to 30 full rows or 8 delta rows | 4 | Expose tasks in the source manifest; attach a materialized projection for task surfaces or fetch it on demand |
| Deep meeting context inside `turn_context` | Up to 40k transcript chars | 4 | Attach meeting identity on meeting surfaces; fetch bounded transcript slices |
| Separate deep meeting-context injection | Same content again | 0 | Remove the duplicate path |
| Persisted message-draft state | Up to lane-state limit | 4 | Include exact pending draft state only when present |
| Attached-file or ambient-screen manifest | Variable | 5 | Explicit user attachments and visible surface references are first-class scope |
| Current user text | Variable | 5 | Always include verbatim |
| HTML execution marker | about 60 chars | 1 | Keep in transport metadata, not model content |
| Prior user and assistant conversation | Variable | 5 | Keep a bounded verbatim tail plus a structured checkpoint |
| Prior Work Index and time injections | Variable, accumulated | 1 | Make current state ephemeral; do not persist stale application projections in conversation history |

The current delta design requires the model to reconstruct live state from historical user-role blocks. Current application state should be materialized outside conversation history and presented or fetched as a fresh versioned projection.

## 4. Tool surface

The ordinary non-code Main surface exposes 42 tools and about 111,722 serialized characters. The issue is not that a general agent has 42 capabilities. It is that discovery and execution schemas are delivered in the same eager layer.

| Capability group | Approximate chars | General-purpose relevance | Correct representation |
| --- | ---: | ---: | --- |
| Context and capability navigation: `context`, `load_user_skill`, `load_skill`, `load_tool_group` | 8,582 | 5 | Always-on compact primitives with typed results |
| Task state and detail: `tasks`, `get_task_context` | 5,038 | 5 | Advertise authoritative task source; load exact query schema on selection |
| Integration discovery and execution | 13,146 | 5 | Keep integration search and describe compact; defer provider operation schemas |
| Meetings, notes, files, screen, and personal files | 12,327 | 4 | Source manifest entries plus bounded exact/search retrieval |
| Workflows and scheduled tasks | 20,066 | 4 | Compact capability entry; full schemas after selection |
| Messaging and drafts | 17,549 | 4 | Compact capability entry; channel-specific tools and policies on demand |
| Document and media creation | 19,007 | 4 | Compact capability category; full creation schemas on demand |
| Web and sandbox | 3,491 | 4 | Universal capability descriptions; full schemas on demand |
| Home state and mutations | 8,497 | 3 | Load on Home-related work |
| Credits and internal reporting | 4,019 | 2 | Load for billing or internal-report intents |

If code mode is enabled, `run_code` adds 3,258 characters and brings the surface to 43 tools. Code mode can attach that schema explicitly without changing the general Main surface.

## 5. Recommended architecture

### 1. Keep a small general operating model

Teach reusable behavior: interpret intent, identify the required evidence, prefer authoritative sources, fetch narrowly, widen on miss, verify freshness, respect approval boundaries, and abstain when a required source is unavailable.

### 2. Add a context-source manifest

Every turn should expose a compact typed map of what can be known: tasks, meetings, approvals, people, files, memory, integrations, screen context, and conversation history. Each entry needs a description, authority, freshness, scope, approximate cost, and retrieval handle.

### 3. Keep universal acquisition primitives always visible

The agent needs a small stable set: inspect sources, exact context lookup, filtered search, and `load_tool_group`. These primitives are the fishing rod. Their results should be typed, bounded, versioned, and attributable.

### 4. Separate discovery from operation schemas

Show compact capability categories and descriptions initially. Load full tool schemas, skill bodies, provider operations, and capability-local policy only after the agent selects them.

### 5. Make the assembler an enforcement layer

The assembler owns budgets, provenance, deduplication, authorization, sensitivity, and freshness. It can attach explicit entity ids and obvious surface state, but the base design should not require a router to predict the complete intent before the agent can work.

### 6. Bound history and keep current state ephemeral

Preserve a recent verbatim tail and a structured checkpoint. Keep task, meeting, approval, and other live projections outside durable conversation history. Reload them by stable reference.

### 7. Remove duplicated representation

Collapse the response contracts, move rendering rules into adapters, remove duplicate meeting injection, and keep one authoritative copy of every context item per model request.

### 8. Evaluate acquisition, not prompt matching

Use a broad replay set with unfamiliar, ambiguous, and cross-domain requests. Measure source selection, acquisition recall, unnecessary fetches, widening success, stale-state use, unsupported negatives, tool-group recovery, task completion, first-call tokens, and total-turn latency. Intent prefetch and deterministic fast paths are later optimizations and must not be required for competence.

## Source map

- Main configuration and compaction: `packages/agent/lib/personalDemiAgentConfig.ts`
- Main policy: `packages/agent/agents/personal_orchestrator/instructions/10_policy.md`
- Shared operating policy: `packages/agent/lib/instructions/operating_policy.md`
- Shared response format: `packages/agent/lib/instructions/response_format.md`
- Main output blocks: `packages/agent/agents/personal_orchestrator/instructions/02_response_format.ts`
- Response reminder injection: `packages/agent/lib/model.ts`, `packages/agent/lib/model.prompt.ts`
- Tool groups: `packages/agent/agents/delegate_to_personal_demi/toolGroups.ts`
- Work Index rendering: `apps/backend/src/features/personal-demi/workIndex.prompt.ts`
- Work Index full/delta loading: `apps/backend/src/features/personal-demi/workIndex.ts`
- Turn context: `packages/agent/agents/personal_orchestrator/instructions/turn_context.ts`
- Duplicate meeting paths: `apps/backend/src/features/personal-demi/orchestratorHandlers.ts`, `packages/agent/lib/instructions/meeting_context.ts`
- Memory snapshot composition: `apps/backend/src/features/context-repository/direct.ts`
- Meeting transcript cap: `apps/backend/src/features/meetings/meetingContextRuntime.ts`
- Prompt source telemetry: `apps/backend/src/infra/ai/contextTokenAnalytics.ts`
