Cedar enables your agent to not only read state but also execute actions through structured responses. This guide shows you how to set up an end-to-end flow where your agent can understand your application state and perform actions on it.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.
Overview
The agentic actions flow consists of four main parts:- Register State Setters - Define what state manipulation actions can be performed
- Register Frontend Tools - Define what other actions can be executed
- Configure Structured Responses - Set up your agent to return structured data
- Handle LLM Results - Process the structured responses and execute actions
Complete Example: Product Roadmap
Let’s walk through a complete example using a product roadmap application where the agent can add features, remove nodes, and manage diffs.Step 1: Register State with Custom State Setters
First, register your state with custom state setters that define the available actions:Step 2: Register Frontend Tools
In addition to state setters, you can register frontend tools that agents can execute directly. These tools handle UI actions, notifications, talking to external systems, and other operations that don’t directly manipulate Cedar state:Step 3: Configure Your Agent for Structured Responses
Configure your agent backend to return structured responses. For state setters, your agent should returnsetState type responses. For frontend tools, your agent should return frontendTool type responses.
Step 4: Handle LLM Results
Cedar’shandleLLMResult function automatically processes both setState and frontendTool responses. It will:
- Find the relevant state setter or frontend tool
- Validate provided args against the
argsSchema(if provided) - Execute the function if args are valid
- Add the message to the chat
Note: This default handling can be customized using Custom Response Processing. You can also customize how setState completion is displayed with Custom Message Rendering.
Using Actions in Your UI
You can trigger actions directly from your UI components:Best Practices
1. Use Descriptive Action Names
Make your setter names clear and action-oriented:2. Use Descriptive Schema Fields
Help your agent understand what parameters to provide using Zod’s describe method for both state setters and frontend tools:3. Use Conditional Tool Registration
Register tools only when they’re relevant to the current state:4. Handle Errors Gracefully
Add error handling in both state setters and frontend tools:Automatic Schema Distribution
Cedar automatically includes the schemas of all registered state setters and frontend tools in the context sent to your agent. This enables your agent to understand both the data structure and what actions are available.Schema Structure
The schemas are included in top-level fields alongside your subscribed state data:Zod Schema Integration
Both state setters and frontend tools use Zod schemas to define parameter validation and provide rich type information to your agent. Cedar automatically converts Zod schemas to JSON Schema format usingzod-to-json-schema and includes them in the context sent to your agent.
To take advantage of this, just register an argsSchema with any state setter or frontend tool.
- Type Safety: Runtime validation of parameters
- Rich Documentation: Descriptive field information for agents
- Automatic JSON Schema: Converted format perfect for LLM understanding
- Consistent API: Single source of truth for parameter definitions
Next Steps
- Learn about State Access for more state management patterns
- Explore Agent Input Context to provide context for actions
- See Custom Message Rendering to display action results

