Documentation Index
Fetch the complete documentation index at: https://docs.declaw.ai/llms.txt
Use this file to discover all available pages before exploring further.
Use case
The OpenAI Agents SDK adapter routes one-shot commands through plainexec, but sometimes an agent needs a real PTY: TUI programs,
progress bars, stateful shell sessions, or anything that calls
isatty(). This recipe shows how to reach the full declaw PTY
module from an adapter session so you get the best of both worlds —
the Agents SDK tool loop and interactive terminal access when you
need it.
What you’ll learn
- Creating an OpenAI adapter session with
DeclawSandboxClient - Reaching the PTY surface via
session._inner._sbx.pty - Sending keystrokes, reading output, and resizing with the async API
- Running a progress bar that would be garbled through a non-PTY pipe
- Verifying env passthrough and shell state persistence across sends
Prerequisites
An
OPENAI_API_KEY is not required for this example. It
exercises the PTY surface directly without making any LLM calls.Code walkthrough
Create the session
Open a PTY through the adapter
The adapter session exposes the underlyingAsyncSandbox so you can
use the PTY module directly:
Four quick probes
Clean up
Running it
Expected output
\r cursor return — a plain exec pipe would have printed
20 separate lines.
Full source
Seecookbook/examples/openai-agents-pty/main.py in the repo.