feat(exa-hosted-key): Restore exa hosted key#3499
feat(exa-hosted-key): Restore exa hosted key#3499TheodoreSpeaks merged 1 commit intofeat/mothership-copilotfrom
Conversation
PR SummaryHigh Risk Overview Introduces a new Adds Written by Cursor Bugbot for commit a56b7ce. This will update automatically on new commits. Configure here. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Greptile SummaryThis PR restores Exa AI hosted-key support, allowing Sim to inject its own Exa API keys when users haven't provided one (or have BYOK configured). The change spans the full billing/rate-limiting stack: a new Key concern: Fragile cost tracking for Exa hosted keys — All four Exa tools throw inside Confidence Score: 4/5
Last reviewed commit: a56b7ce |
| getCost: (_params, output) => { | ||
| const costDollars = output.__costDollars as { total?: number } | undefined | ||
| if (costDollars?.total == null) { | ||
| throw new Error('Exa search response missing costDollars field') | ||
| } | ||
| return { cost: costDollars.total, metadata: { costDollars } } | ||
| }, |
There was a problem hiding this comment.
getCost throws unconditionally when costDollars?.total == null, but __costDollars is typed as optional (the type { total?: number } | undefined acknowledges total may be absent). If the Exa API ever responds without a costDollars field—due to free tier, certain query types, or API version changes—the exception will propagate through applyHostedKeyCostToResult after the Exa API call already succeeded. This causes the entire tool execution to fail, and the successful API result is lost.
Consider returning { cost: 0 } (with a warning log) instead of throwing when cost data is unavailable:
getCost: (_params, output) => {
const costDollars = output.__costDollars as { total?: number } | undefined
if (costDollars?.total == null) {
logger.warn('Exa search response missing costDollars field — skipping cost tracking')
return { cost: 0 }
}
return { cost: costDollars.total, metadata: { costDollars } }
}The same pattern appears in answer.ts, find_similar_links.ts, and get_contents.ts.
Summary
Restore exa hosted key. See: #3221
Fixes #(issue)
Type of Change
Testing
Tested previously with exact same code. See previous pr for testing.
Checklist
Screenshots/Videos