Skip to content

feat: record command attrs on telemetry failure via fallbackAttrs#1204

Open
Hweinstock wants to merge 1 commit into
aws:mainfrom
Hweinstock:feat/telemetry-failure-attrs
Open

feat: record command attrs on telemetry failure via fallbackAttrs#1204
Hweinstock wants to merge 1 commit into
aws:mainfrom
Hweinstock:feat/telemetry-failure-attrs

Conversation

@Hweinstock
Copy link
Copy Markdown
Contributor

@Hweinstock Hweinstock commented May 11, 2026

Description

Adds optional fallbackAttrs parameter to client.withCommandRun so command-specific attributes (language, framework, etc.) are recorded even when the callback throws. Previously failure telemetry only had exit_reason + error_name.

Related Issue

N/A

Documentation PR

N/A

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe):

Testing

How have you tested the change?

  • I ran npm run test:unit and npm run test:integ
  • I ran npm run typecheck
  • I ran npm run lint
  • If I modified src/assets/, I ran npm run test:update-snapshots and committed the updated snapshots

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.

@github-actions github-actions Bot added the size/m PR size: M label May 11, 2026
@github-actions github-actions Bot added the agentcore-harness-reviewing AgentCore Harness review in progress label May 11, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Package Tarball

aws-agentcore-0.13.1.tgz

How to install

npm install https://github.com/aws/agentcore-cli/releases/download/pr-1204-tarball/aws-agentcore-0.13.1.tgz

Copy link
Copy Markdown

@agentcore-cli-automation agentcore-cli-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — clean, focused change that addresses a real gap in failure telemetry.

Verified:

  • fallbackAttrs defaults to {} when not provided, preserving existing behavior for callers that haven't been updated.
  • Object.keys(attrs).length > 0 guard in recordCommandRun correctly skips resilientParse for the empty-attrs case (plain failure/cancel without fallbacks), so the cancel path (recordCommandRun(command, { exit_reason: 'cancel' }, {}, ...)) still behaves as before.
  • Widening CreateAttrs.agent_type from z.enum(['create', 'import']) to AgentType (['create', 'byo', 'import']) is correct — byo is a valid TUI agent type (src/cli/tui/screens/agent/types.ts) that was previously being dropped by strict parse.
  • Moving validation inside the runCliCommand callback (so validation failures go through telemetry) while keeping a separate validation for the dry-run branch avoids double-validation.
  • Tests use real dependencies (InMemorySink, real temp directories via createTelemetryHelper) — no excessive mocking.
  • Telemetry is instrumented for the new behavior, which is the point of the PR.

Nothing to change.

@github-actions github-actions Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label May 11, 2026
@Hweinstock Hweinstock force-pushed the feat/telemetry-failure-attrs branch from 6d8c318 to 4b51a3e Compare May 11, 2026 21:50
@github-actions github-actions Bot added size/s PR size: S and removed size/m PR size: M labels May 11, 2026
@Hweinstock Hweinstock force-pushed the feat/telemetry-failure-attrs branch from 4b51a3e to 7a94482 Compare May 11, 2026 21:51
@github-actions github-actions Bot added size/m PR size: M and removed size/s PR size: S labels May 11, 2026
@Hweinstock Hweinstock force-pushed the feat/telemetry-failure-attrs branch from 7a94482 to b6df589 Compare May 11, 2026 21:53
@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels May 11, 2026
Add optional fallbackAttrs parameter to client.withCommandRun so
command-specific attributes are recorded even when the callback throws.

- client.ts: accept fallbackAttrs, use on failure instead of {}
- client.ts: run resilientParse on all non-empty attrs (not just success)
- cli-command-run.ts: withCommandRunTelemetry passes attrs as fallbackAttrs
- cli-command-run.ts: runCliCommand accepts optional knownAttrs param
- command.tsx: extract knownAttrs upfront, pass to runCliCommand
- client.test.ts: add unit tests for fallbackAttrs behavior
- create-edge-cases.test.ts: assert attrs present on failure entry
@Hweinstock Hweinstock force-pushed the feat/telemetry-failure-attrs branch from b6df589 to b26d44c Compare May 11, 2026 21:59
@github-actions github-actions Bot removed the size/m PR size: M label May 11, 2026
@github-actions github-actions Bot added the size/m PR size: M label May 11, 2026
@Hweinstock Hweinstock marked this pull request as ready for review May 11, 2026 22:08
@Hweinstock Hweinstock requested a review from a team May 11, 2026 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants