-
Notifications
You must be signed in to change notification settings - Fork 0
Split support workflow into specialist agents #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sri-rang
wants to merge
4
commits into
main
Choose a base branch
from
feature/support-subagents
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,23 @@ | ||
| Run riffdesk first: uv run riffdesk/main.py | ||
| Then run this file: uv run agent_tools.py | ||
| # OpenChain / RiffDesk | ||
|
|
||
| A human-in-the-loop customer support demo for the Chinook music store data. | ||
|
|
||
| The support supervisor verifies the customer's identity, then delegates to: | ||
|
|
||
| - a read-only purchase specialist for invoice history and line-item details; | ||
| - an approval-gated refund specialist for refund requests. | ||
|
|
||
| Run the API first: | ||
|
|
||
| uv run python -m riffdesk.main | ||
|
|
||
| Then run the interactive support agent in another terminal: | ||
|
|
||
| uv run python -m deeplyagentic.main | ||
|
|
||
| The API defaults to `http://127.0.0.1:8000` and the demo API key | ||
| `demo-secret-key`. Set `RIFFDESK_API_URL`, `RIFFDESK_API_KEY`, or `API_KEY` to | ||
| override these values. | ||
|
|
||
| customer id: 1 | ||
| email: luisg@embraer.com.br |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """RiffDesk's agent-based customer support application.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| """Shared HTTP client configuration for the RiffDesk API.""" | ||
|
|
||
| import os | ||
|
|
||
| import httpx | ||
|
|
||
| API_BASE_URL = os.environ.get("RIFFDESK_API_URL", "http://127.0.0.1:8000") | ||
| API_KEY = os.environ.get("RIFFDESK_API_KEY", "demo-secret-key") | ||
|
|
||
|
|
||
| def api_client() -> httpx.Client: | ||
| """Return a configured client for the RiffDesk API.""" | ||
| return httpx.Client( | ||
| base_url=API_BASE_URL, | ||
| headers={"X-API-Key": API_KEY}, | ||
| timeout=10.0, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| """Specialist sub-agents available to the RiffDesk supervisor.""" | ||
|
|
||
| from deeplyagentic.subagents.purchase_specialist import purchase_specialist | ||
| from deeplyagentic.subagents.refund_specialist import refund_specialist | ||
|
|
||
| __all__ = ["purchase_specialist", "refund_specialist"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| """Read-only purchase-history specialist definition.""" | ||
|
|
||
| from deeplyagentic.subagents.tools import get_invoice_detail, query_invoices | ||
|
|
||
| purchase_specialist = { | ||
| "name": "purchase-specialist", | ||
| "description": ( | ||
| "Read-only specialist for listing a verified customer's invoices and " | ||
| "explaining the tracks, prices, and quantities on a specific invoice." | ||
| ), | ||
| "system_prompt": ( | ||
| "You are RiffDesk's purchase-history specialist. Use only the verified " | ||
| "customer_id supplied by the supervisor. Handle recent-purchase and " | ||
| "invoice-detail questions with the available read-only tools. Never " | ||
| "perform or promise a refund. Return a concise factual answer to the " | ||
| "supervisor." | ||
| ), | ||
| "tools": [query_invoices, get_invoice_detail], | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| """Approval-gated refund specialist definition.""" | ||
|
|
||
| from deeplyagentic.subagents.tools import get_invoice_detail, request_refund | ||
|
|
||
| refund_specialist = { | ||
| "name": "refund-specialist", | ||
| "description": ( | ||
| "Specialist for confirming an owned invoice and filing a refund request " | ||
| "after explicit human approval." | ||
| ), | ||
| "system_prompt": ( | ||
| "You are RiffDesk's refund specialist. Use only the verified customer_id " | ||
| "supplied by the supervisor. First call get_invoice_detail to verify " | ||
| "ownership and confirm exactly what the invoice contains. Only call " | ||
| "request_refund when the customer's desired invoice and reason are " | ||
| "explicit. The request_refund tool is approval-gated. If ownership " | ||
| "cannot be verified, do not proceed. Return the final outcome to the " | ||
| "supervisor." | ||
| ), | ||
| "tools": [get_invoice_detail, request_refund], | ||
| "interrupt_on": { | ||
| "get_invoice_detail": False, | ||
| "request_refund": {"allowed_decisions": ["approve", "reject"]}, | ||
| }, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| """API-backed tools shared by the RiffDesk specialist sub-agents.""" | ||
|
|
||
| from langchain.tools import tool | ||
|
|
||
| from deeplyagentic.api import api_client | ||
|
|
||
|
|
||
| @tool | ||
| def query_invoices(customer_id: int, limit: int = 10) -> str: | ||
| """Look up a verified customer's recent invoices (id, date, total).""" | ||
| with api_client() as client: | ||
| response = client.get( | ||
| f"/customers/{customer_id}/invoices", params={"limit": limit} | ||
| ) | ||
| if response.status_code == 404: | ||
| return f"No customer found with ID {customer_id}." | ||
| response.raise_for_status() | ||
| return str(response.json()) | ||
|
|
||
|
|
||
| @tool | ||
| def get_invoice_detail(customer_id: int, invoice_id: int) -> str: | ||
| """Return track-level detail for an invoice owned by the customer.""" | ||
| with api_client() as client: | ||
| response = client.get( | ||
| f"/invoices/{invoice_id}", params={"customer_id": customer_id} | ||
| ) | ||
| if response.status_code == 404: | ||
| return f"Invoice {invoice_id} does not belong to customer {customer_id}." | ||
| response.raise_for_status() | ||
| return str(response.json()) | ||
|
|
||
|
|
||
| @tool | ||
| def request_refund(customer_id: int, invoice_id: int, reason: str) -> str: | ||
| """File an approval-gated refund request for an owned invoice.""" | ||
| with api_client() as client: | ||
| response = client.post( | ||
| "/refunds", | ||
| json={ | ||
| "customer_id": customer_id, | ||
| "invoice_id": invoice_id, | ||
| "reason": reason, | ||
| }, | ||
| ) | ||
| if response.status_code == 404: | ||
| return ( | ||
| f"Invoice {invoice_id} does not belong to customer {customer_id}; " | ||
| "refund not filed." | ||
| ) | ||
| response.raise_for_status() | ||
| return str(response.json()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.