## 1. Add llama_flags to Agent type - [ ] 1.1 Add `llama_flags: string | null` to `Agent` interface in `apps/server/src/types/api.ts` - [ ] 1.2 Verify no downstream type errors (tsc --noEmit) ## 2. Parse llama_flags from AGENTS.md frontmatter - [ ] 2.1 Add `llama_flags?: string` to `ParsedFrontmatter` in `apps/server/src/services/agents.ts` - [ ] 2.2 Add explicit `else if (key === 'llama_flags')` branch in `parseFrontmatter()` before the "Unknown keys silently ignored" fallthrough (agents.ts ~line 258) - [ ] 2.3 Add `llama_flags: typeof fm.llama_flags === 'string' ? fm.llama_flags : null` to the return object in `parseAgentSection()` (agents.ts ~line 364) ## 3. Build X-Agent-Flags header - [ ] 3.1 Add `buildAgentFlagsHeader(agent: Agent | null): string | undefined` to `apps/server/src/services/inference/stream-phase-adapter.ts` - [ ] 3.2 Export the function for testability ## 4. Emit header on inference requests - [ ] 4.1 In `streamCompletion()`, compute `agentFlagsHeader` from the agent parameter - [ ] 4.2 Pass `headers: { 'X-Agent-Flags': agentFlagsHeader }` to `streamText()` when non-empty - [ ] 4.3 Verify the header is NOT emitted when agent is null or llama_flags is null/empty ## 5. Fix sentinel summaries (V3) - [ ] 5.1 In `sentinel-summaries.ts`, add `agent` as the 8th argument to the `streamCompletion()` call in `runWrapUpSummary()` (after `signal`) ## 6. Write tests - [ ] 6.1 Add unit test for `buildAgentFlagsHeader` in `stream-phase-adapter.test.ts` (null agent, null llama_flags, empty string, whitespace-only, valid flags) - [ ] 6.2 Add test verifying `streamText` receives `headers: { 'X-Agent-Flags': '...' }` when agent has llama_flags ## 7. Verify end-to-end - [ ] 7.1 Run `pnpm -C apps/server build` to confirm typecheck passes - [ ] 7.2 Run `pnpm -C apps/server test` to confirm no regressions