claude-code - 💡(How to fix) Fix [BUG] Ink renderer crashes with "Box can't be nested inside Text" when rendering subagent system prompt in tmux teammate mode [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52656Fetched 2026-04-24 10:43:14
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×5commented ×1

Error Message

ERROR <Box> can't be nested inside <Text> component at cli.js:502:249 if (K.isInsideText && H === "ink-box") throw Error("<Box> can't be nested inside <Text> component");

Error Messages/Logs

ERROR <Box> can't be nested inside <Text> component throw Error("<Box> can't be nested inside <Text> component"); The spawned tmux pane renders the error immediately during system prompt display; the pane becomes unresponsive and accepts no further input 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:

Code Example

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 };
}
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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.

extent analysis

TL;DR

The issue can be fixed by modifying the Markdown-to-Ink transformer to handle nested inline formatting and tables correctly, or by rewriting the custom subagent definition to avoid triggering the error.

Guidance

  • Identify the specific patterns in the Markdown file that cause the error, such as tables with inline code, nested bold+backtick combinations, and emoji in headings.
  • Rewrite the Markdown file to avoid these patterns, using flat bullets instead of tables and avoiding nested inline formatting.
  • If rewriting the Markdown file is not feasible, consider modifying the Markdown-to-Ink transformer to handle these cases correctly.
  • Test the changes by re-spawning the subagent and verifying that the error no longer occurs.

Example

No code snippet is provided as the issue is related to the Markdown-to-Ink transformer and the specific patterns in the Markdown file.

Notes

The issue is specific to the Claude Code version 2.1.119 and the Anthropic API platform. The bug is triggered by the custom subagent's Markdown file and can be reproduced consistently.

Recommendation

Apply a workaround by rewriting the custom subagent definition to avoid triggering the error, as modifying the Markdown-to-Ink transformer may require significant changes to the underlying code.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING