tracy
AGENTS.md79 starsChanged 9 months agoApache-2.0View on GitHub
Rules for AI agents modifying this codebase. Security - Never commit API keys or credentials - Never log secrets - Use environment variables for sensitive config Sensitive Content Redaction - Tracy redacts AI inputs/outputs by default — do not change this behavior - This is a security requirement, not a bug OpenTelemetry Conventions - Follow OpenTelemetry GenAI semantic conventions - Do not invent custom attribute names Runtime Gating - Spans emit only when SDK is installed via TracingManager.setSdk(...) AND isTracingEnabled…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
15 rules. About 1 is common, 10 are distinctive, and 4 are very specific to this project.
≈1
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Common: line 8
Never commit API keys or credentials
- Distinctive: line 10
Use environment variables for sensitive config
- Distinctive: line 17
Follow OpenTelemetry GenAI semantic conventions
- Distinctive: line 18
Do not invent custom attribute names
- Distinctive: line 26
Keep diffs minimal — no drive-by refactoring
- Distinctive: line 27
Do not add dependencies without justification
- Distinctive: line 28
Add tests for behavior changes
- Distinctive: line 29
Update examples if public API changes
- Distinctive: line 50
Test across all supported Kotlin versions (1.9.0 – 2.3.0) when modifying plugin logic
- Distinctive: line 51
Avoid tracing local (nested) functions
- Distinctive: line 81
Use existing providers as reference.
- Very specific: line 84
Create tracing/{provider}/ module, register it in settings.gradle.kts
- Very specific: line 86
If multiple distinct API endpoints exist, implement EndpointApiHandler per endpoint and delegate from the adapter
- Very specific: line 87
Add a public instrument(client) function — use patchOpenAICompatibleClient() for OpenAI-compatible SDKs, or reflection + …
- Very specific: line 88
Write tests extending BaseAITracingTest, tag with @Tag("{provider}")
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md 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
Agent Instructions
Rules for AI agents modifying this codebase.
Critical Rules
Security
- Never commit API keys or credentials
- Never log secrets
- Use environment variables for sensitive config
Sensitive Content Redaction
- Tracy redacts AI inputs/outputs by default — do not change this behavior
- This is a security requirement, not a bug
OpenTelemetry Conventions
- Follow OpenTelemetry GenAI semantic conventions
- Do not invent custom attribute names
Runtime Gating
- Spans emit only when SDK is installed via
TracingManager.setSdk(...)ANDisTracingEnabledis true - Missing SDK = no-op with minimal overhead — preserve this
Code Quality
- Keep diffs minimal — no drive-by refactoring
- Do not add dependencies without justification
- Add tests for behavior changes
- Update examples if public API changes
Build Commands
./gradlew build # full build
./gradlew allTests # all tests
./gradlew :tracing:core:allTests # module tests
./gradlew publishAllToMavenLocal # publish (NOT plain publish)Skip provider tests: ./gradlew allTests -Dskip.llm.providers=openai,gemini,anthropic
Key Patterns
Context Propagation
withContext,launchpropagate automaticallyrunBlocking, raw threads need manual propagation viacurrentSpanContextElement()/currentSpanContext()
Compiler Plugin
@Traceworks only in Kotlin- Test across all supported Kotlin versions (1.9.0 – 2.3.0) when modifying plugin logic
- Avoid tracing local (nested) functions
Module Layout
tracy/
├── tracing/
│ ├── core/ # Core abstractions, @Trace, exporters, OkHttp support
│ ├── openai/ # OpenAI client integration
│ ├── anthropic/ # Anthropic client integration
│ ├── gemini/ # Gemini client integration
│ ├── ktor/ # Ktor HTTP client integration
│ └── test-utils/ # Shared test utilities
├── plugin/
│ ├── gradle-tracy-plugin/ # Gradle plugin (selects correct compiler plugin)
│ └── tracy-compiler-plugin-*/ # Compiler plugins per Kotlin version (1.9.0–2.3.0)
├── examples/ # Runnable usage examples
└── publishing/ # Composite build publishing logicModule Organization
- tracing/core:
TracingManager,LLMTracingAdapter,EndpointApiHandler, exporters,@Traceannotation - tracing/{openai, anthropic, gemini}: Provider adapters extending
LLMTracingAdapter, endpoint handlers,instrument()functions - tracing/ktor: Ktor HTTP client tracing integration
- plugin/: Kotlin compiler plugins for
@Traceannotation processing - examples/: Reference implementations (keep in sync with API changes)
Adding a New Provider
Use existing providers as reference.
Steps:
- Create
tracing/{provider}/module, register it insettings.gradle.kts - Extend
LLMTracingAdapter(genAISystem)— overridegetRequestBodyAttributes,getResponseBodyAttributes,getSpanName, and abstractregisterResponseStreamEvent - If multiple distinct API endpoints exist, implement
EndpointApiHandlerper endpoint and delegate from the adapter - Add a public
instrument(client)function — usepatchOpenAICompatibleClient()for OpenAI-compatible SDKs, or reflection +patchInterceptors()for others (seeGeminiClient.kt) - Write tests extending
BaseAITracingTest, tag with@Tag("{provider}")
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.

