rajivmehtaflex/power-utility/chrome-prompt-api-pitfalls
Claude Code and agent skill by rajivmehtaflex/power-utility
- community
Checking that the SKILL.md file is still in the repository.
Use for Chrome Prompt API, Pyodide WASM, or COEP apps.
Install
npx vskill@latest install rajivmehtaflex/power-utility/chrome-prompt-api-pitfallsSKILL.md
The same SKILL.md was published earlier as rajivmehtaflex/power-utility/chrome-prompt-api-pitfalls.
Chrome Prompt API + Pyodide WASM Agent Pitfalls
Learned from a debugging session where silent failures hung the agent indefinitely. Each pitfall below produces no console error — the app just stops responding.
Pitfall 1: LanguageModel.create() must be inside a user gesture
Symptom: "Running agent..." hangs forever. No error in console.
Root cause: Chrome's Prompt API requires window.LanguageModel.create() to fire synchronously within a user gesture (click handler). If called from DOMContentLoaded, after an await, or in a .then() chain, Chrome silently refuses or throws a swallowed NotAllowedError.
Fix — call create() directly in the click handler before any await:
Pitfall 2: COEP require-corp blocks all cross-origin CDNs
Symptom: net::ERR_BLOCKED_BY_RESPONSE.NotSameOriginAfterDefaultedToSameOriginByCoep in console. Page renders unstyled or missing scripts.
Root cause: Cross-Origin-Embedder-Policy: require-corp (needed for WASM/SharedArrayBuffer) blocks ANY cross-origin resource that doesn't send Cross-Origin-Resource-Policy headers. Adding crossorigin="anonymous" to the <script> tag does not fix this — the CDN origin must itself send CORP headers, which most don't.
Fix — remove the CDN entirely, use inline CSS or locally-bundled assets:
Pitfall 3: No timeout = silent hang forever
Symptom: Agent never completes, no error, button stays disabled.
Root cause: If the LLM session fails silently (e.g., Pitfall 1), the runAgent() Promise never resolves or rejects. With no timeout, the UI hangs indefinitely.
Fix — always add a timeout + worker.onerror handler:
Pitfall 4: Small models (Gemini Nano) frequently omit toolInput
Symptom: Agent loops to max iterations and returns "Execution halted." even when it correctly selected the right tool.
Root cause: Gemini Nano is a ~2B parameter model. It often returns the correct toolName (e.g., "calculator") but leaves toolInput empty (""), causing the tool to fail on empty input.
Fix — recover tool input from the user prompt via regex fallback:
Architecture pattern that works
The Pyodide Worker + JS Promise bridge pattern is sound:
Key design rules:
- Python
awaiton JS Promises is safe — the Pyodide event loop suspends while JS resolves the Promise - Never re-enter Pyodide concurrently —
LLM_RESPONSEmessages only resolve JS Promises, they don't callrunPythonAsync - Pass JSON text across the boundary, not dicts/PyProxy objects (structured clone fails)
- Use
pyodide.FS.writeFile()to load Python modules, thenrunPythonAsync("import module")
Verification checklist (do ALL before declaring success)
- [ ]
uv run pytest tests/ -vpasses - [ ]
node --checkpasses on all JS files - [ ] Server responds with COOP/COEP headers
- [ ] Drove the browser end-to-end — clicked Run Agent and confirmed a final answer appeared in the UI
- [ ] Console has no red errors after a full run
- [ ] Timeout fires within 90s if something is broken (not silent hang)
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingprofile/software-development/chrome-prompt-api-pitfalls/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/rajivmehtaflex/power-utility/chrome-prompt-api-pitfalls)