Flows category icon
Harness Engineering
Intermediate

Observability for Agent Runs

Instrument your agent like production software: traces, session replay, cost tracking, and failure analysis on open standards.

4 steps12 verify checks90-120 minutesWorks with: emergent · chatgpt · claude · cursor
Start Guided Walkthrough

The Route

0/4 verified

Context Pack

Paste this first. It briefs the AI on requirements, constraints, and the Definition of Done before your first build prompt.

Context Pack
PROJECT CONTEXT:
When my agent misbehaves I scroll raw logs and guess. The agent-observability ecosystem has converged on the answer: structured traces of every step, session replay for debugging, and cost/latency metrics in the same view.

GOAL:
Instrument the agent with structured tracing (OpenTelemetry-compatible), build session replay, track cost per session, and run failure analysis on real data.

REQUIREMENTS:
- Every run traced: model calls, tool executions, decisions as spans with attributes
- Session replay: reconstruct any run step-by-step from stored events
- Cost and token metrics per call, aggregated per session and per task class
- Error and anomaly capture: failures linked to their trace context
- A failure-analysis workflow using the traces, demonstrated on real cases

CONSTRAINTS:
- Use open standards (OpenTelemetry semantics) over bespoke formats where possible
- Sensitive content (secrets, user data) must be scrubbed before storage

DEFINITION OF DONE:
- A session renders as a trace tree: turns, model calls, tool spans with timing
- Any past session replays step-by-step with full payloads (scrubbed)
- Cost per session appears in the session summary and aggregates over time
- One real failure is root-caused via traces, demonstrably faster than log-diving

COMMON FAILURES TO AVOID:
- Unstructured print-logging that cannot reconstruct a run
- Traces without token/cost attributes, blinding the economics
- Secrets in span payloads, turning observability into a breach
- Dashboards built, never used - observability without a debugging workflow

Paste this into your AI builder first. It teaches the AI what you want before you give it the build prompt.

Related routes

More Harness Engineering flows that share ground with this one.

Flows category icon
Harness Engineering

Assemble Tool Prompts Dynamically per Environment

Stop shipping one static mega-prompt: generate tool prompts from environment conditions, inject blocks only when features are on, and dedupe config to save tokens.

01Identify conditional blocks
02Build the prompt generator
03Dedupe and budget every block

+1 more steps to Done

Best forproduction-grade builds with strict verification

4 steps90-120 minutesAdvanced
Flows category icon
Harness Engineering

Cost Control: Model Routing and Effort Tiers

Route work to the cheapest model that can do it and match reasoning effort to task difficulty - with quality guardrails.

01Profile spend by call class
02Build the routing table and wire it
03Add escalation on failure

+1 more steps to Done

Best forproduction-grade builds with strict verification

4 steps90-120 minutesAdvanced
Flows category icon
Harness Engineering

Design Layered Tool Prompts with Preference Chains

Structure your tool prompts the way the leading harness does: preference chains up front, usage constraints in the middle, NEVER-guarded safety protocols at the end.

01Audit the current tool prompt
02Write the preference chain
03Write usage constraints and safety protocols

+1 more steps to Done

Best forbuilders who have shipped a basic app before

4 steps60-90 minutesIntermediate

Made with Emergent