Skip to content

@W-22167805@ add sf agent trace list command#409

Merged
WillieRuemmele merged 27 commits intomainfrom
wr/listTraces
May 8, 2026
Merged

@W-22167805@ add sf agent trace list command#409
WillieRuemmele merged 27 commits intomainfrom
wr/listTraces

Conversation

@WillieRuemmele
Copy link
Copy Markdown
Contributor

@WillieRuemmele WillieRuemmele commented Apr 30, 2026

Work Item

@W-22167805@

Summary

Adds the sf agent trace list command for listing trace files recorded during agent preview sessions. Reads from the local .sfdx/agents/ cache — no org connection required.

Changes

  • New command: sf agent trace list
  • Flags: --agent (substring match, replaces separate --api-name/--authoring-bundle), --session-id, --since (ISO 8601, validated at flag-parse time)
  • Messages: messages/agent.trace.list.md
  • Schema and snapshot updated

Files Changed

  • src/commands/agent/trace/list.ts
  • messages/agent.trace.list.md
  • schemas/agent-trace-list.json
  • command-snapshot.json
  • test/commands/agent/trace/list.test.ts

Test Plan

  • 19 unit tests passing
  • npm run build and npm test pass cleanly
  • Schema and deprecation snapshot regenerated

Dependencies

@WillieRuemmele WillieRuemmele requested a review from a team as a code owner April 30, 2026 16:51
@WillieRuemmele WillieRuemmele changed the title @W-21785101@ add sf agent preview trace list command @W-22167805@ add sf agent trace list command Apr 30, 2026
@EstebanRomero84
Copy link
Copy Markdown
Contributor

QA Notes

I verified that the command list the traces correctly.

Flags

  • since
    ✅ Filters correctly the traces by date when valid ISO 8601 format are used.
    ✅ When incorrect format is used the error message is helpfull.
Screenshot 2026-05-08 at 9 46 48 AM
  • session-id
    ✅ Filters correctly by session Id.
Screenshot 2026-05-08 at 9 47 51 AM
  • agent
    ✅ Filters correctly by agent name.
Screenshot 2026-05-08 at 10 01 23 AM - Combine since` and `agent` ✅ Filters correctly by date and agent name. Screenshot 2026-05-08 at 9 49 06 AM ✅ Json output is correct. Screenshot 2026-05-08 at 10 03 39 AM

EstebanRomero84 and others added 13 commits May 8, 2026 10:13
…written to the project dir

Without cwd, preview start/send/end wrote the session cache relative to the runner's working
directory, causing trace read/delete NUTs to throw SessionNotFound when they ran with
cwd: session.project.dir.
listCachedPreviewSessions only returns sessions still in the index, but
agent preview end removes the entry when it cleans up the active-session
marker. Both trace read and trace delete now fall back to a filesystem
scan of .sfdx/agents/<agentId>/sessions/ so they work on ended sessions.
When sessions are run with --simulate-actions, the turn index exists but
planId entries are null. --turn N now falls back to positional trace file
order rather than throwing TurnIndexNotFound. Also relaxes the grounding
NUT assertion since simulated sessions may not produce LLMExecutionStep
rows with React prompt names.
@W-22167805@ add sf agent trace read command
Move the ended-session filesystem scan into src/agentSessionScanner.ts
so all three trace commands (list, read, delete) share the same logic
and no longer miss sessions that were ended via agent preview end.
Also add missing cwd to the z4.agent.trace.list NUT before() hook.
@W-22167805@ add sf agent trace delete command
@WillieRuemmele WillieRuemmele merged commit 23932d3 into main May 8, 2026
13 checks passed
@WillieRuemmele WillieRuemmele deleted the wr/listTraces branch May 8, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants