Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 5_a2a_integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ In `agents/gamemaster_orchestrator/gamemaster_orchestrator.py`, establish mystic
```python
# TODO: Initialize A2AClientToolProvider with known_agent_urls containing:
a2a_provider = A2AClientToolProvider(known_agent_urls=[
# - "http://127.0.0.1:8000" (The Sage of Rules' tower)
# - "http://127.0.0.1:8001" (The Hall of Heroes)
# - "http://0.0.0.0:8000" (The Sage of Rules' tower)
# - "http://0.0.0.0:8001" (The Hall of Heroes)
])
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ def create_character(

characters_db.insert(asdict(character))
print("Inserted")
print(character)
return character


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from fastapi.responses import JSONResponse
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel
from strands_tools import generate_image

from tinydb import TinyDB, Query

# Load environment variables
load_dotenv()
Expand Down Expand Up @@ -39,21 +40,39 @@ def health_check():
def get_messages():
return agent.messages

# A2A Client for agent communication (workshop-compatible version)
a2a_provider = A2AClientToolProvider(known_agent_urls=[
"http://127.0.0.1:8000", # Rules Agent
"http://127.0.0.1:8001", # Character Agent
])
@app.get("/user/{user_name}")
def get_user(user_name):
characters_db = TinyDB('./../character_agent/characters.json')
Character_Query = Query()
result = characters_db.search(Character_Query.name == user_name)
if not result:
return f":x: Character with name '{user_name}' not found"

character = result[0]
print(f"✅ Found character: {character['name']} (ID: {character['character_id']}, {character['character_class']} {character['race']})")
return character

# TODO: Create A2A Client for agent communication
# Initialize A2AClientToolProvider with known_agent_urls containing:
# - "http://0.0.0.0:8000" (Rules Agent)
# - "http://0.0.0.0:8001" (Character Agent)
a2a_provider = None

# Initialize A2A tools
a2a_tools = list(a2a_provider.tools) if a2a_provider else []
print(f"A2A tools available: {[tool.tool_name for tool in a2a_tools]}")

agent = Agent(
model=os.getenv("MODEL_ID"),
tools=a2a_tools + [generate_image],
tools=a2a_tools,
system_prompt="""You are a D&D Game Master orchestrator. You MUST always consult your specialized agents before responding.

CHARACTER CREATION REQUIREMENT:
BEFORE starting any game session, you MUST ensure the player has a character created and stored in the database:
1. Use a2a_send_message to ask the Character Agent (port 8001) to check if a character exists for this player
2. If no character exists, guide the player through character creation using the Character Agent
3. Only proceed with the game session AFTER confirming the character is created and stored in TinyDB

MANDATORY WORKFLOW:
1. FIRST: Use a2a_list_discovered_agents to see available agents
2. THEN: Use a2a_send_message to consult the appropriate agent(s) for the request
Expand Down Expand Up @@ -89,12 +108,13 @@ def get_messages():

In the "details" of the json, provide the details of the tools and agents you used to generate the response

Remember, the response should ONLY be a PURE json with no markdown or text arount it
Remember, the response should ONLY be a PURE json with no markdown or text arount it.
"""
)

# MCP Client for dice rolling service
mcp_dice_client = MCPClient(lambda: streamablehttp_client("http://localhost:8080/mcp"))
# TODO: Create MCP Client for dice rolling service
# Initialize MCPClient with a lambda that returns streamablehttp_client("http://localhost:8080/mcp")
mcp_dice_client = None

# Add MCP tools to agent
if mcp_dice_client:
Expand Down Expand Up @@ -137,4 +157,6 @@ async def ask_agent(request: QuestionRequest):


if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8009)
# TODO: Start the FastAPI server
# Use uvicorn.run() with app, host="0.0.0.0", and port=8009
pass