[BUG] Ink renderer crashes with "Box can't be nested inside Text" when rendering subagent system prompt in tmux teammate mode

Resolved 💬 5 comments Opened Apr 24, 2026 by kimjaebeom98 Closed Apr 28, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When launching a subagent via Agent Teams in tmux teammate mode, the subagent pane crashes during initial system prompt rendering with:

ERROR <Box> can't be nested inside <Text> component at cli.js:502:249

The pane becomes unusable immediately after spawn. Re-spawning the same subagent reproduces the crash 100%. Other subagents in the same team (with different definition files) render fine, so the trigger is specific Markdown structures in the custom agent definition (~260 lines) — tables with inline-code in cells, nested bold+backtick like text, emoji in section headings, mixed Korean + ASCII punctuation. After rewriting the same content with plain bullets instead of tables and no nested inline formatting, the crash disappears.

Stack trace (from minified cli.js:502, createInstance):
if (K.isInsideText && H === "ink-box") throw Error("<Box> can't be nested inside <Text> component");

Ink's host-context check fires: isInsideText is set by an <ink-text> ancestor, but the React tree emits an <ink-box> child inside it. The Markdown-to-Ink transformer is producing block-level nodes inside inline text context.

What Should Happen?

Markdown rendering should never produce <Box> inside <Text>. The transformer should either flatten offending structures to inline equivalents or render block elements as siblings of the enclosing <Text>. At minimum, a well-formed Markdown agent definition file should never cause Ink to throw during subagent spawn.

Error Messages/Logs

ERROR  <Box> can't be nested inside <Text> component
  at /$bunfs/root/src/entrypoints/cli.js:502:249

// Relevant Ink host-context check (from minified cli.js:502):
createInstance(H, _, q, K, O) {
  if (K.isInsideText && H === "ink-box")
    throw Error("<Box> can't be nested inside <Text> component");
  ...
}

getChildHostContext(H, _) {
  let q = H.isInsideText,
      K = _ === "ink-text" || _ === "ink-virtual-text" || _ === "ink-link";
  if (q === K) return H;
  return { isInsideText: K };
}

Steps to Reproduce

Create a custom subagent definition at ~/.claude/agents/repro-agent.md containing Markdown tables with inline code in cells, nested bold+backtick combinations (e.g. **\text**), emoji in section headings, and mixed Korean + ASCII punctuation. (A concrete ~260-line example is attached.)
Open a tmux session: tmux new -s repro
Launch Claude Code in teammate mode: claude --teammate-mode tmux
In the main pane, call TeamCreate(team_name="test"), then Agent(subagent_type="repro-agent", name="worker", team_name="test", prompt="start")
The spawned tmux pane renders the error immediately during system prompt display; the pane becomes unresponsive and accepts no further input
Killing and re-spawning the same subagent reproduces 100%
Replacing the same file with a structurally simpler Markdown version (bullets instead of tables, no nested inline formatting, no emoji in headings) eliminates the crash — same semantic content, no rendering failure

Claude Model

Not sure / Multiple models

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.119

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

The crash is triggered by the custom subagent's Markdown file (.md in ~/.claude/agents/). Specific patterns that appear to cause the <Box>-in-<Text> error when Ink renders the system prompt:

  1. Markdown tables where cells contain inline code backticks, quoted strings, or Korean + ASCII mixed punctuation
  2. Nested inline formatting: backtick-inside-bold
  3. Emoji at the start of heading lines (⚠️, ✅, ❌)
  4. Bullet items where a sub-element contains triple-backtick fenced code

Rewriting the same semantic content with flat bullets (no tables), no nested inline formatting, and no emoji in headings eliminates the crash 100%. This pins the bug to the Markdown-to-Ink component transformer, not the subagent runtime itself.

Attachments:

  • agent-crashes.md (reproduces)
  • agent-works.md (same content, simplified — no crash)

I can provide a reduced minimal repro (single-section .md) on request.

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗