-
Notifications
You must be signed in to change notification settings - Fork 106
Description
I'm building an automated testing framework for Claude Code agents, and I've hit a wall with interactive TUI prompts.
When Claude Code calls the AskUserQuestion tool (which renders a nice arrow-key navigable menu), AgentAPI times out with:
RuntimeError: Failed to send message: {"title":"Internal Server Error","status":500,"detail":"unexpected
error occurred","errors":[{"message":"failed to send message: failed to send message: failed to wait for
screen to stabilize: timeout waiting for condition"}]}
The issue is that AgentAPI's screen stabilization logic waits for the terminal to stay unchanged for 2 seconds. But AskUserQuestion renders an interactive TUI with a cursor indicator that keeps updating, so the screen never "stabilizes."
What I'm Trying to Do
I'm building automated tests for Claude Code skills and agents. The workflow looks like:
- Test framework sends a task to Claude Code via AgentAPI
- Claude Code invokes a skill that asks a clarifying question with
AskUserQuestion - My test framework detects the prompt (pattern matching on
"enter to select") - Test framework generates a programmatic response (e.g., "1" for the first option)
- Framework attempts to send response via
POST /message - 15-second timeout while waiting for screen to stabilize
What the TUI Looks Like
Here's what Claude Code renders when it calls AskUserQuestion:
What's the main problem you want this fridge inventory app to solve?
❯ 1. Reduce food waste
2. Simplify grocery shopping
3. Meal planning
4. All of the above
5. Type something.
────────────────────────────────────────────────────────────
Enter to select · ↑/↓ to navigate · Esc to cancel
That ❯ indicator shows which option is selected and expects arrow key navigation. It's a nice experience for humans, but causes problems for automated testing.
Why It's Breaking
Here's the sequence:
- AgentAPI detects the TUI prompt (pattern matches on
"enter to select") - My test framework tries to send "1" via
POST /messagewithtype: "user" - AgentAPI waits for screen stabilization (needs 81 consecutive identical snapshots over ~2s)
- The screen never stabilizes because the TUI cursor/indicator keeps rendering
- After 15 seconds: timeout error
I dug into the codebase and found that lib/screentracker/conversation.go requires ScreenStabilityLength (2 seconds) of completely unchanged terminal output. The TUI's interactive nature means that threshold is never met.
Any plans on supporting interactive tools in the future? Any ideas on workarounds besides disabling the tool entirely?