fix(internet-identity): rewrite skill to fix agent hallucinations#101
Open
fix(internet-identity): rewrite skill to fix agent hallucinations#101
Conversation
This was referenced Mar 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Rewrites the
internet-identityskill to eliminate patterns that cause agents to generate broken code. Adds the first evaluation suite for this skill.Closes #97. Supersedes #91.
Mentions #95, #96, #99, #100.
Why wrap
awaitin functions instead ofbuild.target: "esnext"?The original #95 proposed adding
build.target: "esnext"to Vite config. As analyzed in #95 (comment), this is the wrong fix:awaitcomes from skill code examples, not from@icp-sdk/bindgenoutput (verified against generated snapshots)esnextdisables all transpilation — overbroad for a scalpel problemasync function init()works with any Vite target and is how real apps structure initializationWhy hardcode the II canister ID?
Internet Identity has a well-known canister ID (
rdmx6-jaaaa-aaaaa-aaadq-cai) that is the same on mainnet and local replicas. The previous code had a wrong fallback (be2us-64aaa-aaaaa-qaabq-cai) and a dynamicic_envcookie lookup that was unnecessary for II.Why no
fetch: window.fetch.bind(window)?PR #91 added this workaround. It's unnecessary — icp-js-core#1316 fixes this at the SDK level by binding
window.fetchinside the agent constructor.Why use
rootKeyfromic_envinstead ofshouldFetchRootKey?The
ic_envcookie (set by the asset canister or Vite dev server) already contains the root key asIC_ROOT_KEY. Passing it via therootKeyoption toHttpAgent.create()works in both local and production without environment branching. This aligns with the pattern inicp-cli/references/binding-generation.md.fetchRootKey()is a security risk on mainnet.Why remove backend Motoko/Rust examples?
The backend code (anonymous principal rejection, role guards, caller binding) is not II-specific — identical patterns apply regardless of auth method. The
canister-securityskill already has comprehensive coverage. Removing ~170 lines of duplicated content makes the skill leaner and avoids conflicting advice.Changes
Skill (
internet-identity/SKILL.md):awaitin async functions (no top-level await)rdmx6-jaaaa-aaaaa-aaadq-cai(replaces wrong fallback + dynamic lookup)rootKeyfromic_envcookie instead ofshouldFetchRootKey@icp-sdk/auth >= 5.0.0,@icp-sdk/core >= 5.0.0)canister-securityskill)icp-cliskill)ii: truenetwork config2vxsx-fae),fetchRootKeywarningEvaluations (
evaluations/internet-identity.json): New file with 6 output evals + 12 trigger evalsii: true)ic_envcookie pattern)esnextis NOT recommended)