Darkmind / Issue 031

Resolve Identifiers Before an Agent Calls the Tool

Make an agent choose a target from a trusted index, then have code resolve and validate the exact identifier before a tool receives it.

Nov 7, 20264 min readAgent security

An agent can choose the right-looking target and still act on the wrong thing. A customer name may differ by one invisible character. A workspace label can use letters from different scripts that look alike. A copied URL, email address, repository name, or record label can carry formatting that neither the person nor the model notices. If that string flows directly into a tool call, “looks right” becomes an accidental authorization method.

The practical move is to put an identifier-resolution gate between the model’s selection and a consequential tool call. Let the model choose only from a trusted, bounded index or state its selection criteria. Then let application code resolve the candidate to one canonical, stable identifier, validate its allowed representation and scope, and return the exact target for review or execution. The model should never be the final parser of an identity-bearing string.

This is relevant to agent safety because untrusted inputs can change an agent’s behavior and drive unintended tool use.[3] OWASP specifically calls out Unicode smuggling and multilingual or cross-script techniques among prompt-injection obfuscation patterns.[1] Unicode’s security standard defines mechanisms for confusable and mixed-script detection, because visually similar strings can create security problems in identifier contexts.[2] Those sources do not make every non-ASCII name suspicious. They support a narrower rule: identity needs a system-owned check, not visual similarity or a model’s confidence.

Separate the label from the authority

A display label helps a human or model find a candidate. It is not a safe primary key. Keep an internal, stable ID for the tool boundary: a database UUID, provider account ID, repository node ID, opaque workspace ID, or an approved canonical address. Show the label alongside that ID, but bind proposals, approvals, and writes to the stable ID.

If the user has named a target indirectly, begin with a read-only lookup in the already authorized scope. Return a small candidate list with stable IDs and enough metadata to distinguish them. The agent can nominate one entry by its returned ID. If the candidate is ambiguous, visually confusable with another entry, outside the allowed character policy, or inconsistent with the requested scope, stop for clarification or a human check. Do not “helpfully” pick the closest-looking value.

Normalization has a limited role. A system may normalize a value for comparison or detect compatibility characters, but it must retain the original input for audit and apply the same deterministic rules everywhere. Do not normalize and then silently map to an unrelated record. A normalized collision is a reason to reject or disambiguate, not a reason to guess which identity the person meant.

Copy this identifier-resolution gate

Put this contract in the code that sits between model output and any tool that reads sensitive data, updates a record, sends a message, publishes content, or changes permissions.

INPUT FROM AGENT
- requested_target: [label, address, URL, or stable ID]
- authorized_scope: [tenant, project, account, repository]
- intended_operation: [one allowlisted verb]

TRUSTED RESOLUTION (application code)
1. Preserve raw_input exactly for the audit record.
2. If a stable ID was supplied, verify its format and that it belongs to
   authorized_scope. Never reconstruct an ID from a display label.
3. If a label was supplied, query only the authorized scope and return a
   bounded candidate index: {stable_id, display_label, distinguishing fields}.
4. Apply the documented identifier policy:
   - permitted scripts/characters for this identifier class
   - deterministic normalization used only for comparison
   - mixed-script, invisible-character, or confusable-collision flags
5. Resolve only when exactly one candidate is authorized and unambiguous.
6. Bind {stable_id, intended_operation, scope, current_version} to the
   proposal or execution request.

SAFE RESULTS
- resolved: exact stable_id + display label + scope witness
- needs_disambiguation: bounded candidate IDs; no tool call
- rejected_identifier: policy reason; no suggested near match
- out_of_scope: generic denial; no cross-scope lookup

The gate should return a typed result, not a prose warning the model might reinterpret. A needs_disambiguation result may show two approved candidates with their stable IDs and safe differentiators, such as project owner or last four characters of an internal ID. It should not expose a global directory to resolve one ambiguous string. An out_of_scope result should not invite the agent to search a different tenant “just to check.”

Validate the target again at the write boundary

Resolution is not a replacement for authorization, approval, or concurrency checks. Before a write, the executor should re-check that the resolved stable ID is still in scope, that the permitted operation and fields match the approved proposal, and that the record has not changed if the workflow depends on a prior read. The agent’s label, a user’s pasted text, and the earlier lookup are evidence for selecting a target—not credentials for changing it.

OpenAI recommends structured outputs to constrain unexpected text or commands moving between workflow nodes, and recommends that untrusted data not directly drive agent behavior.[3] Use that principle here: pass a small target_id object into the executor, not a free-form label that the model can revise on the way to the call.

Failure mode: treating non-ASCII as an error

An identifier policy that rejects every non-ASCII string will lock out legitimate people, organizations, and internationalized domains while doing little to prove intent. The safe design is per identifier class and per product: support the scripts you need, define their allowed forms, detect collisions in the namespace you actually operate, and offer a review path for legitimate edge cases. Unicode’s mechanisms are detection tools, not a mandate to erase linguistic diversity.[2]

The habit to keep

let people and models use readable names to find a target, but let only trusted code resolve, validate, and bind the stable identifier that reaches a consequential tool.

Sources

  1. OWASP, “LLM Prompt Injection Prevention Cheat Sheet”
  2. Unicode Consortium, “Unicode Security Mechanisms”
  3. OpenAI, “Safety in building agents”