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

# Rename Session

> Auto-generate a workflow session name after a run.

Call `Workflow.set_session_name(autogenerate=True)` after a run to generate a session name.

```python rename_session.py theme={null}
"""
Rename Session
==============

Demonstrates auto-generating a workflow session name after a run.
"""

from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIChat
from agno.tools.websearch import WebSearchTools
from agno.workflow.step import Step
from agno.workflow.steps import Steps
from agno.workflow.workflow import Workflow

# ---------------------------------------------------------------------------
# Create Agents
# ---------------------------------------------------------------------------
researcher = Agent(
    name="Research Agent",
    model=OpenAIChat(id="gpt-5.6-luna"),
    tools=[WebSearchTools()],
    instructions="Research the given topic and provide key facts and insights.",
)

writer = Agent(
    name="Writing Agent",
    model=OpenAIChat(id="gpt-5.6-luna"),
    instructions="Write a comprehensive article based on the research provided. Make it engaging and well-structured.",
)

# ---------------------------------------------------------------------------
# Define Steps
# ---------------------------------------------------------------------------
research_step = Step(
    name="research",
    agent=researcher,
    description="Research the topic and gather information",
)

writing_step = Step(
    name="writing",
    agent=writer,
    description="Write an article based on the research",
)

article_creation_sequence = Steps(
    name="article_creation",
    description="Complete article creation workflow from research to writing",
    steps=[research_step, writing_step],
)

# ---------------------------------------------------------------------------
# Run Workflow
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    article_workflow = Workflow(
        description="Automated article creation from research to writing",
        steps=[article_creation_sequence],
        db=SqliteDb(db_file="tmp/workflows.db"),
    )

    article_workflow.print_response(
        input="Write an article about the benefits of renewable energy",
        markdown=True,
    )

    article_workflow.set_session_name(autogenerate=True)
    print(f"New session name: {article_workflow.get_session_name()}")
```

## Run the Example

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

**1. Install dependencies**

```bash theme={null}
uv pip install -U agno ddgs fastapi openai sqlalchemy
```

**2. Export your OpenAI API key**

```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"
```

**3. Run the example**

Save the code above as `rename_session.py`, then run:

```bash theme={null}
python rename_session.py
```

Full source: [cookbook/04\_workflows/06\_advanced\_concepts/session\_state/rename\_session.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/04_workflows/06_advanced_concepts/session_state/rename_session.py)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.