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

# Router with CEL expression: route from session_state

> Uses session_state.preferred_handler to persist routing preferences across workflow runs.

```python cel_session_state_route.py theme={null}
"""Router with CEL expression: route from session_state.
=====================================================

Uses session_state.preferred_handler to persist routing preferences
across workflow runs.

Requirements:
    pip install cel-python
"""

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.workflow import CEL_AVAILABLE, Step, Workflow
from agno.workflow.router import Router

# ---------------------------------------------------------------------------
# Setup
# ---------------------------------------------------------------------------
if not CEL_AVAILABLE:
    print("CEL is not available. Install with: pip install cel-python")
    exit(1)

# ---------------------------------------------------------------------------
# Create Agents
# ---------------------------------------------------------------------------
detailed_agent = Agent(
    name="Detailed Analyst",
    model=OpenAIChat(id="gpt-4o-mini"),
    instructions="You provide detailed, in-depth analysis with examples and data.",
    markdown=True,
)

brief_agent = Agent(
    name="Brief Analyst",
    model=OpenAIChat(id="gpt-4o-mini"),
    instructions="You provide brief, executive-summary style analysis. Keep it short.",
    markdown=True,
)

# ---------------------------------------------------------------------------
# Create Workflow
# ---------------------------------------------------------------------------
workflow = Workflow(
    name="CEL Session State Router",
    steps=[
        Router(
            name="Analysis Style Router",
            selector="session_state.preferred_handler",
            choices=[
                Step(name="Detailed Analyst", agent=detailed_agent),
                Step(name="Brief Analyst", agent=brief_agent),
            ],
        ),
    ],
    session_state={"preferred_handler": "Brief Analyst"},
)

# ---------------------------------------------------------------------------
# Run Workflow
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    print("--- Using session_state preference: Brief Analyst ---")
    workflow.print_response(input="Analyze the current state of cloud computing.")
    print()

    # Change preference
    workflow.session_state["preferred_handler"] = "Detailed Analyst"
    print("--- Changed preference to: Detailed Analyst ---")
    workflow.print_response(input="Analyze the current state of cloud computing.")
```

## Run the Example

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno cel-python fastapi openai
    ```
  </Step>

  <Step title="Export your OpenAI API key">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export OPENAI_API_KEY="your_openai_api_key_here"
      ```

      ```bash Windows theme={null}
      $Env:OPENAI_API_KEY="your_openai_api_key_here"
      ```
    </CodeGroup>
  </Step>

  <Step title="Run the example">
    Save the code above as `cel_session_state_route.py`, then run:

    ```bash theme={null}
    python cel_session_state_route.py
    ```
  </Step>
</Steps>

Full source: [cookbook/04\_workflows/07\_cel\_expressions/router/cel\_session\_state\_route.py](https://github.com/agno-agi/agno/blob/main/cookbook/04_workflows/07_cel_expressions/router/cel_session_state_route.py)
