fix patch gateway feat/phase-2g-bundle
AI Agent git-import/068377df · 116 days ago · Apr 1, 2026 · Diff

fix(gateway): eliminate redundant ICP round trips for enrich and hints

Enrich was reliably hitting the Netlify 10 s function limit because the handler made four ICP calls: getHostedAccessContext (bridge) + GET proposal + POST enriched + GET proposal again to build the response. The final GET is redundant — the frontend calls openProposal() + loadProposals() after the enrich request completes, which already re-fetches the updated proposal. Replacing the GET+res.send block with an immediate { ok: true } cuts one full ICP round trip (~1–3 s) from the critical path.

Hints were timing out inside their 6 s budget because runHostedProposalReviewHintsJob made its own GET to the canister to fetch proposal path + body, even though that data is already present in the proposal-create response that triggered the job. Pass the parsed path + body from the canister response to the job via the new optional proposalData field; when provided, the GET is skipped.

Revised worst-case timing (slow ICP, ~1.5 s per call): Enrich: bridge (0.3 s) + GET proposal (1.5 s) + LLM (1.5 s) + POST (1.5 s) = ~4.8 s Hints: POST proposal (1.5 s) + LLM (1.5 s) + POST hints (1.5 s) = ~4.5 s + overhead

Both now fit comfortably inside the 10 s free-tier limit without relying on the per-function timeout configuration.

sha256:268b7c552938200a21f0198aceb7e724bec41cc7432499b88f0e187ebc8d3af3 sha
sha256:47f7c0052eeab9ab3fbe4bb95294ae0bba45d1b9feceae552014adfc8d096042 snapshot
← Older Oldest on feat/phase-2g-bundle
All commits
Newer → Latest on feat/phase-2g-bundle

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:268b7c552938200a21f0198aceb7e724bec41cc7432499b88f0e187ebc8d3af3 --body "your comment"