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

# Interactive REPL

> Drive the agent turn by turn from your terminal, in one session.

A small read-eval-print loop over one session, so each turn builds on the last.
Handlers answer the agent's questions inline; steps stream as it works.

```python theme={null}
from cosmon_agent_sdk import Client, Confirmation, Question, TextChunk, ToolCall

def answer(q: Question) -> str:
    return input(f"{q.prompt} {q.options or ''}\n> ")

def approve(c: Confirmation) -> bool:
    return input(f"{c.summary} [y/N] ").strip().lower() == "y"

with Client(on_question=answer, on_confirm=approve) as client:
    with client.session(agent="nexus") as chat:        # one conversation across turns
        while (prompt := input("\nyou> ").strip()) not in ("/quit", ""):
            for event in chat.run(prompt):
                if isinstance(event, TextChunk):
                    print(event.text, end="", flush=True)
                elif isinstance(event, ToolCall) and not event.finished:
                    print(f"\n▶ {event.summary}")
```

If the agent hands off to another agent, later turns follow it. Leaving the
session (quit) ends the conversation.

<Card title="Guide: multi-turn sessions" icon="book-open" href="/sdk/guide#multi-turn-sessions">
  How sessions keep and resume context.
</Card>
