Cedar allows your agent to understand what is happening in your application, and the ability to change it. Registering a local state in Cedar is the first step to giving your agent frontend context, letting users point out parts of the UI to the agent, and letting agents manipulate state. In other words, it allows your agent to read and write to the local react state. To understand how we internally execute and render actions on your state (and how to override default behavior and rendering for state changes), read SetState Response Processing and SetState Message Rendering.Documentation Index
Fetch the complete documentation index at: https://docs.cedarcopilot.com/llms.txt
Use this file to discover all available pages before exploring further.
useRegisterState Hook
Register your existing React state with Cedar using theuseRegisterState hook:
useCedarState
UseuseCedarState to create and manage state directly in the Cedar store. It directly replaces useState and works the exact same way, but
Accessing Cedar State Functions
executeStateSetter
Execute state setter functions programmatically using the Cedar store:Agent Actions: State setters can be automatically invoked by your agent through structured responses. Learn more about SetState Response Processing and SetState Message Rendering to see how agents can execute these setters and display the results.
Automatic Cleanup: States are automatically unregistered when components unmount, ensuring clean state management without manual cleanup.
Schema Validation with Zod
Cedar OS has runtime validation of setter arguments using Zod schemas:getCedarState
Retrieve the current state value for a registered Cedar state key:setCedarState
Directly update the state value for a registered Cedar state key:Exposing states to your agent
Now that your application states are registered in Cedar, learn how to expose just the right pieces of them to your agent:- Agent Input Context – orchestrate what context is sent alongside every user message, including state subscriptions and manual entries. See Agent Input Context.
- Mentions – let users reference individual state items with simple
@mentions. See Mentions.

