feat: add agentcore traces command and trace link in invoke TUI#493
feat: add agentcore traces command and trace link in invoke TUI#493
agentcore traces command and trace link in invoke TUI#493Conversation
jesseturner21
left a comment
There was a problem hiding this comment.
Review feedback
Remove --target option from traces commands
The --target option should be removed from both traces list and traces get. There isn't a user story for multiple targets right now, so we shouldn't expose that concept here. This would simplify the commands and avoid confusion.
Specific changes needed:
-
src/cli/commands/traces/command.tsx— Remove.option('--target <name>', 'Select deployment target')from both subcommands (lines 26 and 96) -
src/cli/commands/traces/types.ts— Removetarget?: stringfrom bothTracesListOptionsandTracesGetOptions -
src/cli/commands/traces/action.ts— SimplifyresolveAgentto just use the single available target instead of accepting/validating a target selection. The function currently handles target lookup, missing target errors, and target name matching (lines 34-48) — all of that can be simplified to just grabtargetNames[0].
Coverage Report
|
Add traces support with three features: 1. `agentcore traces list` - Lists recent traces for a deployed agent by querying CloudWatch Logs Insights. Supports --agent, --target, and --limit options. Displays trace ID, timestamp, and session ID. 2. `agentcore traces get <traceId>` - Downloads a full trace to a JSON file from CloudWatch Logs. Supports --agent, --target, and --output options. Saves OpenTelemetry span data to agentcore/.cli/traces/. 3. Trace console link in invoke TUI header - Shows the CloudWatch console URL for viewing traces alongside the existing log link. Both commands also print the CloudWatch console URL for quick access to the trace dashboard. New dependency: @aws-sdk/client-cloudwatch-logs
Multiple targets are not currently supported, so remove the --target flag from both `traces list` and `traces get` to avoid exposing an unsupported concept. The commands now always use the single deployed target. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The polling loop only waited 30 seconds and silently fell through to a misleading "No trace data found" error on timeout. Increase to 60s and add an explicit timeout check matching the pattern in list-traces.ts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Match the get-trace timeout increase for consistency. Large log groups may need more than 30 seconds for CWL Insights queries to complete. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Truncating IDs made them unusable as input to `traces get`. Display the full values so users can copy-paste trace IDs directly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
a23d9b5 to
c54f175
Compare
c54f175 to
0d80860
Compare
0d80860 to
e753053
Compare
e753053 to
41543a5
Compare
41543a5 to
75b584f
Compare
75b584f to
ee03efc
Compare
ee03efc to
d390463
Compare
d390463 to
ddf9a5d
Compare
…aces list Extract duplicate agent resolution logic into a shared resolve-agent utility (src/cli/operations/resolve-agent.ts) used by both logs and traces commands. Move time-parser to shared utils (src/lib/utils/time-parser.ts). Add --since and --until flags to `traces list` for custom time range queries instead of the hardcoded 12h window. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ddf9a5d to
838c36b
Compare
Move the repeated 'DEFAULT' endpoint name string to DEFAULT_ENDPOINT_NAME in cli/constants.ts and use it across logs/action.ts, get-trace.ts, list-traces.ts, and trace-url.ts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Compute traceUrl at the top of the render block instead of using an inline IIFE in the JSX. Simplifies the template to a straightforward conditional render. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Return an error early if the user passes a non-numeric value for --limit instead of silently passing NaN to the CloudWatch query. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reject non-hex trace IDs early to prevent query syntax injection and give a clearer error for malformed input. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Description
Add
agentcore tracescommand with two subcommands for viewing and downloading agent traces, plus a trace console link in the invoke TUI header.agentcore traces list— queries CloudWatch Logs Insights to display recent traces for a deployed agent, with--agentand--limitoptionsagentcore traces get <traceId>— downloads full trace data (OpenTelemetry spans) to a JSON file, with--agentand--outputoptionsBoth CLI commands also print the CloudWatch console URL for quick access to the trace dashboard.
New dependency:
@aws-sdk/client-cloudwatch-logsRelated Issue
Closes #
Documentation PR
Type of Change
Testing
How have you tested the change?
npm run test:unitandnpm run test:integnpm run typechecknpm run lintsrc/assets/, I rannpm run test:update-snapshotsand committed the updated snapshotsAdditionally performed full end-to-end manual testing:
Here are the screenshots
result of the list command:





result of the get command:
the link to console in the get command:
open of the json file for the downloaded trace:
Invoke on the tui experience with the link:
Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.