Skip to content

Question: when does ToolPermissionContext.tool_use_id arrive as None? #844

@Rul1an

Description

@Rul1an

Been building a tiny external-consumer adapter around can_use_tool for evidence and review purposes. The seam feels really clean: the callback gives us tool_name, the tool_input dict, and a ToolPermissionContext carrying tool_use_id. That is everything a per-call policy gate needs, and it is materially simpler than reaching into message state.

One small thing we want to get right upfront. The SDK types annotate ToolPermissionContext.tool_use_id as str | None:

class ToolPermissionContext:
    signal: Any | None
    suggestions: list[PermissionUpdate]
    tool_use_id: str | None
    agent_id: str | None

For our use case, tool_use_id is what we use to correlate each policy decision back to the originating tool call in later audit. If it arrives as None, we have to fall back to a synthesized placeholder, which works but is not ideal.

Question: under what circumstances does tool_use_id actually arrive as None at the callback? Is that only hit on legacy or edge paths, or is it a real possibility for normal query() flows? Knowing when to expect None would let us calibrate the fallback path cleanly.

Tiny adapter that currently handles this defensively lives at Rul1an/Assay-Harness for reference.

Thanks for building the SDK. It has been a pleasure to work with.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions