Prompt Pipeline
Every conversation turn dynamically assembles agent instructions before calling the LLM via the @openai/agents SDK. This page describes how the harness builds per-turn context.
Source files:
packages/harness/src/runtime/skill-resolver.ts— per-turn skill resolutionpackages/harness/src/runtime/runner.ts— turn orchestrationpackages/web/api/src/functions/converse.ts— HTTP handler
Assembly Order
POST /api/converse arrives
│
├─ 1. Session lookup or creation
├─ 2. Guardrail input check (core/token-budget, etc.)
│
├─ 3. Runner selects active Agent
│ session.activeAgent ?? "core.triage"
│
├─ 4. Dynamic instructions assembled per turn
│ = agent.body (base .agent.md text)
│ + resolvedSkills(agent.name, recentTurns) ← skill resolver
│ + catalog snapshot (component type list)
│
├─ 5. Agent streams via SDK — text chunks + tool calls
│ core.emit_ui → a2ui SSE events
│ core.write_file, azure.arm_get, etc.
│
├─ 6. UserAction encountered?
│ → pause, emit user_action_required SSE
│ → browser acts (MSAL popup, GitHub OAuth, etc.)
│ → POST /api/converse/resume with typed result
│ → Runner resumes
│
├─ 7. Guardrail output check
│
└─ 8. AgentOutput { message, intent } → SSE done
Skill Resolution
resolveSkills(agentName, context) in packages/harness/src/runtime/skill-resolver.ts:
- Match
appliesTo— glob each skill'sappliesTofield against the current agent name. - Keyword scoring — score matched skills against the recent conversation turns.
- Priority ordering — sort by
priority(higher first), apply token budget cap (2000 tokens default). - Inject — append skill text to the agent's dynamic instructions.
Skills are authored as SKILL.md files inside packs. They are pure text — no code, no execution.
Agent Instructions Structure
{agent.body} ← base .agent.md text (persona + rules)
## Active Skills
{skill1 text}
---
{skill2 text}
## Component Catalog
{registered component list with schemas}
Guardrails
Guardrails contributed by packs run at three stages:
| Stage | When |
|---|---|
input | Before the agent receives the user message |
tool | Before each tool call result is returned to the agent |
output | After AgentOutput is produced |
Built-in guardrails: core/token-budget, core/content-safety. Pack guardrails: azure/no-hardcoded-creds, aks/no-privileged-containers, etc.