> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Resolve Trace Hook • AI Agent SDK

> resolve_trace_hook: Return ``hook`` when a tracer is supplied, else the no-op default.

# resolve\_trace\_hook

<div className="flex items-center gap-2">
  <Badge color="teal">Function</Badge>
</div>

> This function is defined in the [**protocols**](../modules/protocols) module.

Return `hook` when a tracer is supplied, else the no-op default.

A tiny helper so a gateway can accept an optional `tracer=` argument and
always hold a callable hook without branching on `None` at every stage.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#8B0000', 'primaryTextColor': '#fff', 'primaryBorderColor': '#710101', 'lineColor': '#189AB4', 'secondaryColor': '#189AB4', 'tertiaryColor': '#fff' }}}%%

graph TD
    event["Event Trigger"] --> hook["Hook: resolve_trace_hook"]
    hook --> decision{"Decision"}
    decision -- "Allow" --> proc["Process"]
    decision -- "Deny" --> block["Block"]
    style hook fill:#189AB4,color:#fff
    style event fill:#8B0000,color:#fff
    style proc fill:#8B0000,color:#fff
    style block fill:#8B0000,color:#fff
```

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def resolve_trace_hook(hook: 'Optional[GatewayTraceHook]') -> 'GatewayTraceHook'
```

## Parameters

<ParamField query="hook" type="'Optional[GatewayTraceHook]'" required={true}>
  A user/plugin-supplied trace hook, or `None`.
</ParamField>

### Returns

<ResponseField name="Returns" type="'GatewayTraceHook'">
  data:`NULL_GATEWAY_TRACE_HOOK`.
</ResponseField>

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/gateway/protocols.py#L4897">
  `praisonaiagents/gateway/protocols.py` at line 4897
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Hooks Concept" icon="anchor" href="/docs/docs/concepts/hooks" />

  <Card title="Hook Events" icon="bolt" href="/docs/docs/features/hook-events" />

  <Card title="Callbacks" icon="phone" href="/docs/docs/features/callbacks" />
</CardGroup>
