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.0.tar.gz (15.4 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.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ag2tracer-0.1.0.tar.gz
  • Upload date:
  • Size: 15.4 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.0.tar.gz
Algorithm Hash digest
SHA256 850d390bf6859969eb013a39b56c52947cd3cfa205280d62f8dd1151883b24e7
MD5 afe44b21113c1c9cfbd594e002d7493d
BLAKE2b-256 c12cae1975cc93a2731d7518d81f198104a4dba30660c4a3ada19f0c2fe46fde

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ag2tracer-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.0 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 65af7ce81446a3ab053cc486e5f7d6852af9e725afb14f7f9573328028fabff7
MD5 71c8be6c5b437c93e0e91ff003f5bc07
BLAKE2b-256 092068d431644915015afd094278d902c23de33e29f81e48696a0fe8d33ecc39

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