Skip to content

Commit 2cd0c4e

Browse files
committed
fix: report agent URLs instead of PRs
Treat Cursor/Devin responses as async agent runs and only report PRs when explicitly returned, avoiding false success messages in Omi chat.
1 parent 967c17e commit 2cd0c4e

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

main.py

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,8 @@ async def root(uid: str = Query(None)):
10171017
const status = entry.success ? 'OK' : 'ERR';
10181018
const msg = entry.message || '';
10191019
const url = entry.pr_url ? ' PR: ' + entry.pr_url : '';
1020-
lines.push('[' + entry.provider + '] ' + status + ' ' + msg + url);
1020+
const agentUrl = entry.agent_url ? ' Agent: ' + entry.agent_url : '';
1021+
lines.push('[' + entry.provider + '] ' + status + ' ' + msg + url + agentUrl);
10211022
}}
10221023
logsEl.value = lines.join('\\n');
10231024
if (!logs.length && data.message) {{
@@ -1430,11 +1431,22 @@ async def test_agent(request: Request):
14301431
continue
14311432

14321433
data = result.get("data") or {}
1434+
pr_url = None
1435+
agent_url = None
1436+
if agent_provider == "cursor":
1437+
target = data.get("target") or {}
1438+
pr_url = target.get("prUrl")
1439+
agent_url = target.get("url") or data.get("url")
1440+
elif agent_provider == "devin":
1441+
agent_url = data.get("url")
1442+
else:
1443+
pr_url = data.get("pr_url") or data.get("pull_request_url")
14331444
logs.append({
14341445
"provider": provider_label,
14351446
"success": True,
14361447
"message": result.get("message") or "Command sent",
1437-
"pr_url": data.get("pr_url") or data.get("pull_request_url"),
1448+
"pr_url": pr_url,
1449+
"agent_url": agent_url,
14381450
"data": data
14391451
})
14401452

@@ -1536,11 +1548,27 @@ async def tool_code_feature(request: Request):
15361548
return ChatToolResponse(error=f"Failed to implement feature: {result.get('message')}")
15371549

15381550
data = result.get("data") or {}
1539-
pr_url = data.get("pr_url") or data.get("pull_request_url") or data.get("url")
1540-
pr_number = data.get("pr_number") or data.get("pull_request_number")
15411551
default_branch = data.get("default_branch") or get_default_branch(owner, repo_name, user["access_token"])
15421552
returned_branch = data.get("branch") or branch_name
15431553

1554+
# Provider-specific parsing
1555+
pr_url = None
1556+
pr_number = None
1557+
agent_url = None
1558+
agent_status = None
1559+
1560+
if agent_provider == "cursor":
1561+
target = data.get("target") or {}
1562+
pr_url = target.get("prUrl")
1563+
agent_url = target.get("url") or data.get("url")
1564+
agent_status = data.get("status")
1565+
elif agent_provider == "devin":
1566+
agent_url = data.get("url")
1567+
agent_status = data.get("status") or data.get("session_id")
1568+
else:
1569+
pr_url = data.get("pr_url") or data.get("pull_request_url")
1570+
pr_number = data.get("pr_number") or data.get("pull_request_number")
1571+
15441572
if pr_url:
15451573
if merge and data.get("merged") is True:
15461574
return ChatToolResponse(
@@ -1566,6 +1594,16 @@ async def tool_code_feature(request: Request):
15661594
result=f"✅ **Feature implemented!**\n\n**Pull Request:** {pr_url}\n\nReview the AI-generated code and merge when ready."
15671595
)
15681596

1597+
if agent_provider in ("cursor", "devin"):
1598+
status_line = f"Status: {agent_status}" if agent_status else "Status: running"
1599+
url_line = f"URL: {agent_url}" if agent_url else ""
1600+
return ChatToolResponse(
1601+
result="✅ **Agent started**\n\n"
1602+
f"{status_line}\n"
1603+
f"{url_line}\n\n"
1604+
"The agent is running asynchronously. A PR will appear once it finishes."
1605+
)
1606+
15691607
# If provider only pushed a branch, create PR via GitHub API
15701608
pr_title = f"AI: {feature[:60]}"
15711609
pr_body = f"""## Feature Request

0 commit comments

Comments
 (0)