Skip to content

show picks the first match when a short id is ambiguous #9

Description

@royalpinto007

Desired outcome

agentrace show <id> tells the user when the id they gave is ambiguous, instead of silently picking one run.

Why it matters

cmd_show() in agentrace/cli.py:

match = [r for r in runs if r.tool_use_id.endswith(args.id)]
if not match:
    console.print(f"[red]No run matching {args.id!r}[/]")
    return 1
r = match[0]

The command deliberately accepts a short id, and cmd_list prints exactly that short form (r.tool_use_id[-8:]), so short ids are the normal way to use this. But endswith is a suffix match on an arbitrary user string. agentrace show 1 matches every run whose id ends in "1", and the user is shown match[0] with no indication that seven other runs matched. The header prints the full tool_use_id, but nobody re-reads an id they just typed, and across sessions run ids are not shown side by side.

Silently showing the wrong run in a triage tool is worse than an error: the user reads a result, forms a judgement, and attributes it to a different agent run.

Steps

  1. When len(match) > 1, print the matching ids with their descriptions and return non-zero, asking the user to be more specific.
  2. Allow the obvious escape hatch: if one of the matches is an exact tool_use_id, use it without complaint.
  3. r.description can be None, in which case the header currently prints the literal "None". cmd_list already handles this with (r.description or "(none)"), so reuse that.
  4. Add a test in tests/test_agentrace.py with two runs sharing an id suffix, asserting a non-zero exit.

Claiming this

Comment below to claim it. A reply usually comes within a day.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions