Metadata-Version: 2.4
Name: duetmachines
Version: 0.1.0
Summary: Send production conversations to Duet Machines.
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Provides-Extra: openai-agents
Requires-Dist: openai-agents>=0.23; extra == "openai-agents"

# duetmachines

Send your AI agent's production conversations and business outcomes to [Duet Machines](https://platform.duetmachines.com),
which grades them against your expert's standard, builds tests from them and proves cheaper models on them.

```bash
pip install duetmachines
```

The client posts from a background thread and never raises into your code: if Duet Machines is unreachable, your agent
keeps working and the conversation is logged as not sent.

## Conversations

```python
from duetmachines import DuetMachines

duet = DuetMachines(api_key=os.environ["DUET_API_KEY"], agent="<agent id from Traffic › Connect>")

convo = duet.conversation(
    ticket.id,                      # your id; posting again replaces the conversation
    user_id=customer.id,            # links outcomes that arrive later
    version="2026.11.1",            # your release, to compare versions
    config={"instructions": SYSTEM_PROMPT, "tools": TOOLS, "model": "gpt-5.4-mini"},
)
convo.customer(user_message)
convo.tool("lookup_order", {"order_id": "A123"}, {"status": "shipped"}, duration_seconds=0.4)
convo.agent(reply, usage={"input_tokens": 812, "output_tokens": 64, "model": "gpt-5.4-mini"})
convo.end()
```

`usage` on agent turns prices what each conversation costs, so savings can be projected. `config` lets graders and
tests judge each conversation against the instructions and tools it ran with.

## Outcomes

Send business outcomes whenever they happen, from your billing system, CRM or help desk:

```python
duet.outcome("payment_received", id=payment.id, user_id=customer.id, value=149.00, currency="USD")
duet.outcome("ticket_reopened", id=f"reopen-{ticket.id}", conversation=ticket.id)
```

Declare each outcome name on the agent's Traffic › Outcomes page first.

## OpenAI Agents SDK

```bash
pip install "duetmachines[openai-agents]"
```

```python
from agents import add_trace_processor
from duetmachines.openai_agents import DuetMachinesProcessor

add_trace_processor(DuetMachinesProcessor(duet, version="2026.11.1"))
```

Every agent run is posted as a conversation with no other code.

Docs: https://platform.duetmachines.com/docs
