Link agents to CMPA company, route CEO wakeup per-company
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 8s
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 8s
Created 7 agents in CMPA (betterment levy) company, mirroring the CMP agents with same config and hierarchy. CEO_AGENTS dict maps company_id to the correct CEO for wakeup routing. wake_ceo_agent and post_comment now resolve the correct CEO based on company_id. create_workflow_issue returns company_id. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2200,7 +2200,7 @@ async def api_start_workflow(case_number: str):
|
|||||||
|
|
||||||
# 3. Wake the CEO agent
|
# 3. Wake the CEO agent
|
||||||
try:
|
try:
|
||||||
wakeup = await pc_wake_ceo(issue["issue_id"], case_number)
|
wakeup = await pc_wake_ceo(issue["issue_id"], case_number, issue.get("company_id", ""))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning("CEO wakeup failed for case %s: %s", case_number, e)
|
logger.warning("CEO wakeup failed for case %s: %s", case_number, e)
|
||||||
wakeup = {"error": str(e)}
|
wakeup = {"error": str(e)}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ PAPERCLIP_DB_URL = os.environ.get(
|
|||||||
)
|
)
|
||||||
|
|
||||||
PLUGIN_ID = "53461b5a-7f58-411a-9952-72f9c8d4a328" # marcusgroup.legal-ai
|
PLUGIN_ID = "53461b5a-7f58-411a-9952-72f9c8d4a328" # marcusgroup.legal-ai
|
||||||
CEO_AGENT_ID = "752cebdd-6748-4a04-aacd-c7ab0294ef33"
|
|
||||||
PAPERCLIP_API_URL = os.environ.get("PAPERCLIP_API_URL", "http://localhost:3100")
|
PAPERCLIP_API_URL = os.environ.get("PAPERCLIP_API_URL", "http://localhost:3100")
|
||||||
PAPERCLIP_BOARD_API_KEY = os.environ.get("PAPERCLIP_BOARD_API_KEY", "")
|
PAPERCLIP_BOARD_API_KEY = os.environ.get("PAPERCLIP_BOARD_API_KEY", "")
|
||||||
|
|
||||||
@@ -31,6 +30,14 @@ COMPANIES = {
|
|||||||
"betterment": "8639e837-4c9d-47fa-a76b-95788d651896", # CMPA — היטלי השבחה
|
"betterment": "8639e837-4c9d-47fa-a76b-95788d651896", # CMPA — היטלי השבחה
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# CEO agent per company — used for wakeup routing
|
||||||
|
CEO_AGENTS = {
|
||||||
|
COMPANIES["licensing"]: "752cebdd-6748-4a04-aacd-c7ab0294ef33", # CMP CEO
|
||||||
|
COMPANIES["betterment"]: "cdbfa8bc-3d61-41a4-a2e7-677ec7d34562", # CMPA CEO
|
||||||
|
}
|
||||||
|
# Default for backwards compat
|
||||||
|
CEO_AGENT_ID = CEO_AGENTS[COMPANIES["licensing"]]
|
||||||
|
|
||||||
# Fallback mapping — used only when DB lookup returns no results
|
# Fallback mapping — used only when DB lookup returns no results
|
||||||
_FALLBACK_APPEAL_TYPE_TO_COMPANY = {
|
_FALLBACK_APPEAL_TYPE_TO_COMPANY = {
|
||||||
"רישוי": COMPANIES["licensing"],
|
"רישוי": COMPANIES["licensing"],
|
||||||
@@ -297,6 +304,7 @@ async def create_workflow_issue(case_number: str, title: str) -> dict:
|
|||||||
return {
|
return {
|
||||||
"issue_id": issue_id,
|
"issue_id": issue_id,
|
||||||
"identifier": identifier,
|
"identifier": identifier,
|
||||||
|
"company_id": company_id,
|
||||||
"project_url": project_url,
|
"project_url": project_url,
|
||||||
}
|
}
|
||||||
finally:
|
finally:
|
||||||
@@ -435,9 +443,10 @@ async def post_comment(issue_id: str, company_id: str, body: str) -> dict:
|
|||||||
finally:
|
finally:
|
||||||
await conn.close()
|
await conn.close()
|
||||||
|
|
||||||
# Wake CEO so it processes the comment
|
# Wake the correct CEO for this company
|
||||||
|
ceo_id = CEO_AGENTS.get(company_id, CEO_AGENT_ID)
|
||||||
try:
|
try:
|
||||||
url = f"{PAPERCLIP_API_URL}/api/agents/{CEO_AGENT_ID}/wakeup"
|
url = f"{PAPERCLIP_API_URL}/api/agents/{ceo_id}/wakeup"
|
||||||
payload = {
|
payload = {
|
||||||
"source": "on_demand",
|
"source": "on_demand",
|
||||||
"triggerDetail": "manual",
|
"triggerDetail": "manual",
|
||||||
@@ -456,15 +465,17 @@ async def post_comment(issue_id: str, company_id: str, body: str) -> dict:
|
|||||||
return {"comment_id": comment_id, "issue_id": issue_id, "method": "db_fallback"}
|
return {"comment_id": comment_id, "issue_id": issue_id, "method": "db_fallback"}
|
||||||
|
|
||||||
|
|
||||||
async def wake_ceo_agent(issue_id: str, case_number: str) -> dict:
|
async def wake_ceo_agent(issue_id: str, case_number: str, company_id: str = "") -> dict:
|
||||||
"""Wake the CEO agent via Paperclip's wakeup API.
|
"""Wake the CEO agent via Paperclip's wakeup API.
|
||||||
|
|
||||||
MUST use API, never direct DB insert (agent won't wake from DB insert).
|
MUST use API, never direct DB insert (agent won't wake from DB insert).
|
||||||
|
Routes to the correct CEO based on company_id.
|
||||||
"""
|
"""
|
||||||
if not PAPERCLIP_BOARD_API_KEY:
|
if not PAPERCLIP_BOARD_API_KEY:
|
||||||
raise RuntimeError("PAPERCLIP_BOARD_API_KEY not set — cannot wake CEO agent")
|
raise RuntimeError("PAPERCLIP_BOARD_API_KEY not set — cannot wake CEO agent")
|
||||||
|
|
||||||
url = f"{PAPERCLIP_API_URL}/api/agents/{CEO_AGENT_ID}/wakeup"
|
ceo_id = CEO_AGENTS.get(company_id, CEO_AGENT_ID)
|
||||||
|
url = f"{PAPERCLIP_API_URL}/api/agents/{ceo_id}/wakeup"
|
||||||
payload = {
|
payload = {
|
||||||
"source": "on_demand",
|
"source": "on_demand",
|
||||||
"triggerDetail": "manual",
|
"triggerDetail": "manual",
|
||||||
|
|||||||
Reference in New Issue
Block a user