Conversation
|
👋 This PR can use the first-failure repair loop on GitHub Actions and Buildkite. Labels
Comments
|
✅MegaLinter analysis: Success
Notices📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining See detailed reports in MegaLinter artifacts MegaLinter is graciously provided by OX Security |
|
First failed job: Check SPDX license header Run: https://github.com/elastic/cli/actions/runs/35374182817 |
There was a problem hiding this comment.
🟡 Changes recommended
Clean binary builds cannot resolve the unbuilt package, and some detected harnesses are still omitted from telemetry.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds agent-harness and LLM attribution to CLI telemetry through a new reusable environment-detection package.
Changes:
- Detects agent harnesses and models from environment variables.
- Adds attribution to User-Agent and client-meta headers.
- Updates packaging, tests, licensing, and documentation.
File summaries
| File | Description |
|---|---|
src/lib/meta.ts |
Integrates detected attribution into telemetry headers. |
test/lib/meta.test.ts |
Tests telemetry attribution and opt-out behavior. |
packages/agent-env/src/index.ts |
Implements agent and model detection. |
packages/agent-env/test/index.test.ts |
Tests detection, confidence, and normalization. |
packages/agent-env/README.md |
Documents the detection package. |
packages/agent-env/package.json |
Defines the new workspace package. |
packages/agent-env/tsconfig.json |
Configures TypeScript compilation. |
packages/agent-env/LICENSE |
Adds package licensing. |
packages/config-resolver/package.json |
Makes the existing package publishable. |
packages/config-resolver/LICENSE |
Adds package licensing. |
package.json |
Adds and bundles the new dependency. |
package-lock.json |
Locks workspace and dependency changes. |
tsconfig.json |
Adds the new project reference. |
NOTICE.txt |
Updates bundled dependency notices. |
scripts/openrouter-models.mjs |
Adds an ancillary model-listing utility. |
Review details
Suppressed comments (1)
test/lib/meta.test.ts:228
- Despite the comment, this snapshots only five of the detector's marker variables. An inherited marker such as
CURSOR_TRACE_IDmakes the “no agent” case return Cursor metadata and can make the Claude case low-confidence. Use the complete detector input set so these tests are harness-independent.
describe('agentMetaSegment', () => {
// Snapshot every env var agentMetaSegment can read so branch tests are
// deterministic regardless of the harness running the suite.
const AGENT_VARS = ['AI_AGENT', 'AGENT', 'CLAUDECODE', 'CLAUDE_CODE', 'PI_CODING_AGENT']
const snapshot = new Map(AGENT_VARS.map((k) => [k, process.env[k]]))
- Files reviewed: 13/15 changed files
- Comments generated: 13
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Assisted-by: Pi Coding Agent (Claude Sonnet 4.5)
Include the LLM model name (with vendor prefix when provided by agent-env) in the user-agent string as a semicolon-separated token inside the existing parenthetical, e.g.: elastic-cli/0.5.0 (linux x64; Node.js v22.x.x; anthropic/claude-sonnet-4-6) Assisted-by: Pi Coding Agent (Claude Sonnet 4.6)
faf0979 to
a676935
Compare
isKnownAgent used `v in AGENT_SHORT_CODES` which walks the prototype chain, so AGENT=constructor or AGENT=toString would pass the guard and be treated as a known agent. agentMetaOf used a bracket read without an own-property check, so AI_AGENT=constructor would resolve to the Object constructor function and stringify it into the ag= client-meta header. - isKnownAgent: Object.hasOwn(AGENT_SHORT_CODES, v) - agentMetaOf: guard with Object.hasOwn before reading the short code Assisted-by: Pi Coding Agent (Claude Sonnet 4.5)
The README documents these vars as taking priority over the marker table, but collectVotes was appending them as extra votes. AI_AGENT=devin + CLAUDECODE=1 produced two disagreeing votes (confidence 0.5), failing the default 0.95 threshold and silently discarding the explicit opt-in. collectVotes now returns early when AI_AGENT or AGENT is set, so the marker table is skipped entirely. The winning agent is always the opt-in value with confidence 1 -- matching the documented override semantics. Assisted-by: Pi Coding Agent (Claude Sonnet 4.5)
c0cbcc3 to
3a06295
Compare
|
PR type mismatch: title uses The diff adds a new agent-env package and new telemetry headers for the spawning harness rather than correcting a bug. This affects the version bump and changelog entry release-please generates on merge. Update the PR title (and squash commit message) to match, or push a follow-up commit that justifies the current prefix. |
@elastic/agent-envstandalone packagex-elastic-client-metaFixes #397