implement-agent-observability
Skill4 starsChanged 3 months agoMITView on GitHub
WHEN/WHERE/WHO: [Scheduling: Developers or DevOps engineers deploying autonomous agents to production who need to monitor costs and behavior.] HOW: [Structural: Use this SKILL to inject trace IDs, token tracking, and structured logging into all agent tool calls and state transitions.] WHY: [Scheduling: Agents are non-deterministic black boxes. Without observability, debugging an infinite loop or a hallucinated tool call in production is impossible.]
In this repository61 other files it gives its agents.
- activate-personalSkill
- analyze-with-tactics-questionnairesSkill
- apply-agile-testing-quadrantsSkill
- apply-architectural-tacticsSkill
- apply-attribute-driven-designSkill
- apply-fundamentals-of-data-visualizationSkill
- apply-oopsi-modelSkill
- apply-screenplay-patternSkill
- apply-specification-by-exampleSkill
- blog-topic-discoverSkill
- build-agent-memory-systemsSkill
- build-business-objectives-modelSkill
- build-data-dictionarySkill
- build-feature-treeSkill
- comment-alive-test-driven-developmentSkill
- conduct-event-stormingSkill
- create-ecosystem-mapSkill
- create-living-documentationSkill
- create-skill-from-bookSkill
- CREATING-SKILL-TEMPLATESkill
- define-architectural-driversSkill
- define-bounded-contextsSkill
- define-ubiquitous-languageSkill
- design-agentic-screenplay-modelSkill
- design-agent-perception-layersSkill
- design-agent-planningSkill
- design-agent-reward-functionsSkill
- design-agents-using-patternsSkill
- design-architecture-viewpointsSkill
- design-autonomous-ai-interfacesSkill
- design-ddd-aggregatesSkill
- design-tool-use-sandboxingSkill
- document-architectural-decisionsSkill
- document-legacy-codebaseSkill
- doc-with-usage-exampleSkill
- draft-srs-documentSkill
- elicit-requirements-modelsSkill
- evolve-skill-with-wikiSkill
- extract-business-rulesSkill
- facilitate-example-mappingSkill
- facilitate-user-story-mappingSkill
- implement-agent-reflectionSkill
- improve-existing-skillSkill
- improve-user-storySkill
- managing-ai-projectsSkill
- orchestrate-multi-agent-collaborationSkill
- prioritize-requirementsSkill
- review-c4-modelSkill
- review-data-engineeringSkill
- save-as-skillSkill
- scaffold-cmake-cxx-sanitize-gtest-envSkill
- skill-commonSkill
- task-commit-triggerSkill
- test-case-with-demoSkill
- test-case-with-readmeSkill
- test-driven-developmentSkill
- UnitTesting-convert2CaTDDSkill
- update-my-resumeSkill
- update-spec-contextSkill
- validate-requirements-criteriaSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 8 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
When this skill is activated, first load skill-common and apply the shared conventions it defines: canonical section order, frontmatter …
- Distinctive: line 45
Transfer Check: Verify the workflow still works across local logs, tracing backends, and mixed sub-agent/tool execution paths.
- Distinctive: line 46
Stop Rule: If loop limits, trace propagation, or PII scrubbing cannot be guaranteed, stop and fix those boundaries before broadening …
- Distinctive: line 49
PII Scrubbing: Ensure sensitive user prompts or environment variables (like API keys) are masked before they are sent to the telemetry …
- Very specific: line 50
Strict Parent-Child Tracing: Every sub-agent call or tool execution MUST carry the trace_id of the root user request to allow full …
- Very specific: line 53
If the requested agent logic does not have a strict max_iterations counter built into its state schema, stop and force the implementation …
- Distinctive: line 73
If using a DAG orchestrator (like LangGraph), log every state mutation.
- Distinctive: line 77
Run a simulated failure (e.g., pass a bad argument to a tool intentionally).
- Distinctive: line 78
Verify that the trace correctly captures the LLM decision, the tool failure, and the LLM's recovery attempt, all linked under a single …
- Distinctive: line 85
Do traces capture decision, tool call, state transition, token cost, and loop count under one trace ID?
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Implement Agent Observability
Common Contract (Load First)
When this skill is activated, first load skill-common and apply the shared conventions it defines: canonical section order, frontmatter rules, anti-pattern guidance, and the Review In Mind loop in review-in-mind. This skill adds only domain-specific rules below.
Who
Developers, DevOps engineers, and coding agents preparing to move autonomous LLM systems from prototype into production environments.
What
Design and implement structured trace logging, token counting, cost tracking, and loop-detection limits across the entire agentic system architecture.
When
- Triggered by requests like: "add observability to this agent", "track tokens for this LangGraph", "how do I debug this agent?", or "implement agent logging".
- Mandatory before deploying any agentic loop that executes tools or incurs variable API costs.
Where
Applies to orchestration frameworks, LLM client wrappers, and tool execution decorators in the workspace.
Why
When a traditional app crashes, you get a stack trace. When an agent fails, it might quietly burn $5 in API costs running the same failed git command 500 times. Implementing deep observability (like LangSmith, OpenTelemetry, or custom structured logging) is the only way to debug autonomous behavior and prevent financial runaway.
Inputs
- Current Architecture: The orchestration framework being used.
- Monitoring Stack: The target logging system (e.g., Datadog, LangSmith, local JSON lines).
Output (Logical Evidence)
- Instrumentation Code: Wrappers, callbacks, or decorators injected into the agent graph.
- Telemetry Schema: The specific metadata logged per event (Trace ID, Step, Token Usage, Tool Status).
Optimization Readiness
- Failure Signals: Traces cannot reconstruct a full run, telemetry leaks secrets, tool and sub-agent events lose the root trace ID, or observability is added without loop limits and simply records runaway behavior.
- Evidence To Collect: Sample traces, scrubbed payloads, parent-child run graphs, cost logs, and examples of failures that observability did or did not explain.
- Safe Mutation Boundaries: Refine event schemas, logging wrappers, scrubbing rules, and dashboard/reporting examples without changing the core trace propagation and instrumentation requirements.
- Acceptance Criteria: Accept revisions only if a single request can be reconstructed end to end, sensitive fields are masked, and loop or cost anomalies become observable quickly.
- Rejected Revision Handling: Record telemetry fields that exposed too much data, tracing gaps, and noisy logging patterns so they are not repeated.
- Transfer Check: Verify the workflow still works across local logs, tracing backends, and mixed sub-agent/tool execution paths.
- Stop Rule: If loop limits, trace propagation, or PII scrubbing cannot be guaranteed, stop and fix those boundaries before broadening telemetry.
Constraints (Logical Boundaries)
- PII Scrubbing: Ensure sensitive user prompts or environment variables (like API keys) are masked before they are sent to the telemetry backend.
- Strict Parent-Child Tracing: Every sub-agent call or tool execution MUST carry the
trace_idof the root user request to allow full waterfall reconstruction.
One More Thing
If the requested agent logic does not have a strict max_iterations counter built into its state schema, stop and force the implementation of loop limits before adding observability.
How (Structural Workflow)
1. Establish the Trace ID Hierarchy
- Generate a unique
RunIDorTraceIDat the absolute start of the user request. - Pass this ID down into the state schema so every node, sub-agent, and tool has access to it.
2. Wrap LLM Calls
- Implement callbacks or use built-in handlers (like LangChain's
BaseCallbackHandler) to intercept every LLM request and response. - Log the exact prompt sent, the raw response received, and the
usagemetadata (Prompt Tokens, Completion Tokens, Total Cost).
3. Decorate Tool Executions
- Wrap every tool function with a logging decorator.
- The log MUST capture: Tool Name, Input Arguments (scrubbed), Execution Time (latency), and the Output/Exception returned.
- Example structure:
[TRACE_ID][TOOL][START] name=search_web args={"query": "React 19"}->[TRACE_ID][TOOL][END] status=success duration=1.2s
4. Implement State Transition Logging
- If using a DAG orchestrator (like LangGraph), log every state mutation.
- "Node X completed. Next Node: Y. State updated with 2 new messages." This allows developers to replay the exact graph traversal.
5. Validate the Telemetry
- Run a simulated failure (e.g., pass a bad argument to a tool intentionally).
- Verify that the trace correctly captures the LLM decision, the tool failure, and the LLM's recovery attempt, all linked under a single Trace ID.
Review In Mind (ReviewInMindGenie)
Execute the common review loop in review-in-mind before delivering.
Review lens for this skill:
- Do traces capture decision, tool call, state transition, token cost, and loop count under one trace ID?
- Are sensitive inputs scrubbed and are latency/cost metrics real rather than placeholders?
- Would a simulated failure be diagnosable end to end from the logs?
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

