Back to Copilotkit

State Streaming Setup

showcase/integrations/google-adk/docs/setup/state-streaming-setup.mdx

1.69.31005 B
Original Source
<Steps> <Step> ### Install the ADK + AG-UI bridge
```bash
pip install ag-ui-adk
```
</Step> <Step> ### Declare the predicted state mapping
ADK state streaming uses `PredictStateMapping` to map the streaming
`write_document` tool argument into `state["document"]`. Add
`AGUIToolset()` to the agent so CopilotKit can forward the state deltas to
the UI.

<DemoCode file="src/agents/shared_state_streaming_agent.py" region="state-streaming-middleware" />
</Step> <Step> ### Stop after the final model response
The agent above imports `stop_on_terminal_text` and registers it as its
`after_model_callback`. This prevents Gemini from issuing the same tool
call again after its final text response. See the canonical
[`stop_on_terminal_text` implementation](https://github.com/CopilotKit/CopilotKit/blob/main/showcase/integrations/google-adk/src/agents/shared_chat.py)
when adapting the callback for your project.
</Step> </Steps>