Skip to main content

Failure attribution on multi-agent traces

Project description

ag2tracer

Failure attribution on multi-agent traces. Given a conversation trace from a multi-agent system, ag2tracer identifies which agent made the decisive error and at which step.

Installation

pip install ag2tracer

Setup

Set at least one API key:

export OPENAI_API_KEY="your-openai-key"
export ANTHROPIC_API_KEY="your-anthropic-key"   # optional
export GOOGLE_API_KEY="your-google-key"          # optional

Web Interface

# Launch the web UI
ag2tracer launch

# Or run in background
ag2tracer launch --daemon

# Other commands
ag2tracer status    # check if server is running
ag2tracer logs      # view server logs
ag2tracer logs -f   # follow logs
ag2tracer stop      # stop the background server

Then open http://127.0.0.1:8500 to:

  1. Upload a trace JSON file (must contain a history field)
  2. Browse the conversation with a sliding-window viewer
  3. Select an attribution method and click Start
  4. View the failure-responsible agent and decisive error step

Python API

import json
from ag2tracer import all_at_once, step_by_step, binary_search

with open("trace.json") as f:
    trace = json.load(f)

# Choose a method
result = all_at_once(trace, model="gpt-4o")
# result = step_by_step(trace, model="gpt-4o")
# result = binary_search(trace, model="gpt-4o")

print(f"Agent: {result.agent_name}")
print(f"Step:  {result.step_number}")
print(f"Reason: {result.reason}")

Trace Format

A trace is a JSON object with a required history array:

{
  "history": [
    {"role": "assistant", "name": "Excel_Expert", "content": "..."},
    {"role": "user", "name": "Computer_terminal", "content": "..."},
    ...
  ],
  "question": "optional problem description",
  "ground_truth": "optional expected answer"
}

Attribution Methods

Method Description LLM Calls
All-at-Once Feeds entire conversation to the LLM 1
Step-by-Step Evaluates each step sequentially, stops at first error Up to N
Binary Search Recursively narrows down the error location O(log N)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ag2tracer-0.1.1.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ag2tracer-0.1.1-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file ag2tracer-0.1.1.tar.gz.

File metadata

  • Download URL: ag2tracer-0.1.1.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for ag2tracer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d01afb08652c1833161b32988d6c4eed9d52daa8c9f3e40eea0cecbe82376ad9
MD5 3513602178b29e1a2d7a532d8189ef85
BLAKE2b-256 00fb813fb73a42de979b73d9566294d3c0674b66d86d1e61900a255deafd6f6a

See more details on using hashes here.

File details

Details for the file ag2tracer-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ag2tracer-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for ag2tracer-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c79ed4101f8c9da685ae83186382d0221cd2f6cc507ed1c3e05fbcf96f773ec6
MD5 86455f61d249b69c6366a2fe7b109f2c
BLAKE2b-256 8b5b1beed39458ebc57c240f704236647d7ffd5758189fc97b004a25939ab5ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page