> ## 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.

# Decode Client Frame • AI Agent SDK

> decode_client_frame: Validate a raw inbound frame into a typed, discriminated client frame.

# decode\_client\_frame

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

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

Validate a raw inbound frame into a typed, discriminated client frame.

This is the single source of truth for the gateway wire contract: it
decodes every advertised inbound method (`hello`, `message`, `leave`)
and the legacy `join` handshake into a validated dataclass, or raises
:class:`FrameDecodeError` carrying a structured :class:`HelloError` for the
transport to reject with. Field coercion/validation happens once, here, at
the WebSocket boundary — handlers receive already-typed objects.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def decode_client_frame(data: Dict[str, Any]) -> ClientFrame
```

## Parameters

<ParamField query="data" type="Dict[str, Any]" required={true}>
  The raw, JSON-decoded inbound frame (discriminated on `type`).
</ParamField>

### Returns

<ResponseField name="Returns" type="ClientFrame">
  class:`HelloParams`, :class:`MessageParams`,
  :class:`LeaveParams`, or :class:`JoinParams`.
</ResponseField>

### Exceptions

<AccordionGroup>
  <Accordion title="FrameDecodeError">
    When `data` is not a mapping, carries an unknown /
  </Accordion>
</AccordionGroup>

## Uses

* `FrameDecodeError`
* `HelloError`
* `MessageParams.from_frame`
* `LeaveParams.from_frame`
* `JoinParams.from_frame`

## Source

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

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Code Agent" icon="code" href="/docs/docs/features/codeagent" />

  <Card title="Code Feature" icon="terminal" href="/docs/docs/features/code" />
</CardGroup>
