claude-code - 💡(How to fix) Fix [BUG] Agent-team teammate pane crashes with "<Box> can't be nested inside <Text>" when ※ recap renders inline markdown code spans [8 comments, 8 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#51855Fetched 2026-04-23 07:43:07
View on GitHub
Comments
8
Participants
8
Timeline
19
Reactions
14
Author
Assignees
Timeline (top)
commented ×8labeled ×6subscribed ×2assigned ×1

In Claude Code v2.1.117 agent-teams mode, if a teammate's reply to team-lead contains inline markdown code spans (backtick-delimited text like `uv run python`), the teammate's own pane crashes when Claude Code renders the ※ recap: compact-summary line. The Ink reconciler throws Error: <Box> can't be nested inside <Text> component from createInstance at cli.js:495:249. The crashed pane subsequently causes the whole team directory (~/.claude/teams/{name}/) to be torn down, cascading to all other teammates.

This is distinct from #49865 (different error, different line, different trigger — and #49865 is fixed as of v2.1.114).

Error Message

Error: <Box> can't be nested inside <Text> component at createInstance /$bunfs/root/src/entrypoints/cli.js:495:249 at BU cli.js:477:57938 at gTH / XWH / bgH / Ir / MWH / T_ / hH / eH (React Fiber reconciler + Ink host config work loop)

Root Cause

Option B is probably more robust because it fixes the code-span component regardless of where it's used.

Fix Action

Fix / Workaround

Workaround (current)

Code Example

Error: <Box> can't be nested inside <Text> component
    at createInstance  /$bunfs/root/src/entrypoints/cli.js:495:249
    at BU              cli.js:477:57938
    at gTH / XWH / bgH / Ir / MWH / T_ / hH / eH
       (React Fiber reconciler + Ink host config work loop)

---

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 };
}

---

<Text>
  ※ recap: <InlineMarkdown content={previewText}/>
</Text>

---

<Box backgroundColor="gray" paddingX={1}>
  <Text>uv run python</Text>
</Box>

---

// Buggy:
<Text>
  ※ recap: <InlineMarkdown content={preview}/>
</Text>

// Fixed:
<Box>
  <Text>※ recap: </Text>
  <InlineMarkdown content={preview}/>
</Box>

---

// Buggy:
<Box backgroundColor="gray" paddingX={1}><Text>{code}</Text></Box>

// Fixed:
<Text backgroundColor="gray"> {code} </Text>
RAW_BUFFERClick to expand / collapse

Title: [BUG] Agent-team teammate pane crashes with "<Box> can't be nested inside <Text>" when ※ recap renders inline markdown code spans

Summary

In Claude Code v2.1.117 agent-teams mode, if a teammate's reply to team-lead contains inline markdown code spans (backtick-delimited text like `uv run python`), the teammate's own pane crashes when Claude Code renders the ※ recap: compact-summary line. The Ink reconciler throws Error: <Box> can't be nested inside <Text> component from createInstance at cli.js:495:249. The crashed pane subsequently causes the whole team directory (~/.claude/teams/{name}/) to be torn down, cascading to all other teammates.

This is distinct from #49865 (different error, different line, different trigger — and #49865 is fixed as of v2.1.114).

Environment

  • Claude Code: v2.1.117 (confirmed), v2.1.116 (strongly suspected based on retrospective matching against prior session stalls, not re-tested)
  • Platform: macOS (Darwin 24.5.0)
  • Terminal: iTerm2 inside tmux (tmux -CC control mode)
  • Model: Sonnet 4.6 / Opus 4.7 (both observed)
  • Feature flag: CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1

Error (verbatim, from crashed pane)

Error: <Box> can't be nested inside <Text> component
    at createInstance  /$bunfs/root/src/entrypoints/cli.js:495:249
    at BU              cli.js:477:57938
    at gTH / XWH / bgH / Ir / MWH / T_ / hH / eH
       (React Fiber reconciler + Ink host config work loop)

The throw site in the bundled source:

createInstance(H, _, q, K, O) {
  if (K.isInsideText && H === "ink-box")
    throw Error("<Box> can't be nested inside <Text> component");

Combined with the host-context tracker a few lines earlier:

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

This confirms an ink-box host element is being mounted while the parent context has isInsideText: true.

Reproduction

  1. Start a Claude Code session with CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1.
  2. Call TeamCreate to create a team.
  3. Spawn a teammate via Agent(subagent_type=..., team_name=..., name=...) whose persona or spawn prompt encourages replies containing inline code formatting. (I reproduced with an agent whose spawn reply included the phrase `uv run python`, but any backtick-delimited inline code in the reply is sufficient.)
  4. After the teammate sends its first reply to team-lead and goes idle, Claude Code renders the ※ recap: compact summary in the teammate's own pane.
  5. At that render, the crash fires. Pane shows Ink error-boundary fallback (which, with tmux alternate-screen off, also mis-paints and dumps bundled cli.js source into the pane).
  6. The whole team directory is torn down shortly after.

Expected: recap renders code spans inline, like the main message render does. Actual: Ink reconciler throws from createInstance, pane enters zombie state, team is torn down.

Root-cause hypothesis

The ※ recap: component structure appears to be:

<Text>
  ※ recap: <InlineMarkdown content={previewText}/>
</Text>

Where InlineMarkdown emits a <Box> wrapper for code spans (for background-color / padding visual treatment):

<Box backgroundColor="gray" paddingX={1}>
  <Text>uv run python</Text>
</Box>

The <Box> lands inside the outer <Text> wrapper → violates Ink's getChildHostContext invariant → throw.

Suggested fix

Two clean options:

Option A — change recap's outer wrapper from <Text> to <Box>, move prefix into inner <Text>:

// Buggy:
<Text>
  ※ recap: <InlineMarkdown content={preview}/>
</Text>

// Fixed:
<Box>
  <Text>※ recap: </Text>
  <InlineMarkdown content={preview}/>
</Box>

Option B — change the inline-code-span renderer to use <Text>-level styling instead of <Box> wrapping:

// Buggy:
<Box backgroundColor="gray" paddingX={1}><Text>{code}</Text></Box>

// Fixed:
<Text backgroundColor="gray"> {code} </Text>

Option B is probably more robust because it fixes the code-span component regardless of where it's used.

Evidence the bug is specific to recap rendering (not message receipt)

The main message render in team-lead's pane rendered the same backticked content correctly. Only the ※ recap: line in the teammate's own pane crashed. That points at a separate renderer path that wraps message content in a stricter container.

Selective-crash pattern across a 5-agent team

In one session, spawned 5 teammates. Only the two whose replies/received-content included backticks crashed:

teammatereply contentbackticks?outcome
plannerbare idlenoclean
devbare idlenoclean
qabare idle on spawn; later received brief with backticks from team-leadno / yes (later)clean on spawn, silent-stall later
researcherbare idlenoclean
testermulti-line narrative with `uv run python`yespane crash + source dump

Also: crash fires mid-render of the ※ recap: line specifically — ✶ Doing… / ✢ Doing… status lines (which lack backticks) rendered cleanly before the crash.

Amplifier (orthogonal, self-fixed)

If the user's ~/.tmux.conf has set-option -g alternate-screen off, the Ink error-boundary fallback mis-paints and dumps ~2000 lines of bundled cli.js source into the pane (reproduced this myself). With tmux's default alternate-screen on, the fallback renders a clean error screen. This is user-side config and not Claude Code's responsibility, but worth noting for anyone reproducing.

Related issues

  • #49865 — getAppState is not a function crash on permission-prompt render. Different bug, fixed in v2.1.114. I initially wondered if they were related; they are not.

Workaround (current)

Include an explicit directive in teammate spawn prompts to ban backticks in SendMessage replies. Example: "NEVER use backticks, code fences, or inline code formatting in SendMessage content. Reference paths and identifiers as plain prose." This sidesteps the crash but is fragile (depends on agent compliance).

extent analysis

TL;DR

The most likely fix is to change the recap's outer wrapper from <Text> to <Box> or modify the inline-code-span renderer to use <Text>-level styling instead of <Box> wrapping.

Guidance

  1. Verify the root cause: Confirm that the crash occurs due to the ink-box element being mounted inside a Text component with isInsideText: true.
  2. Apply Option A fix: Change the recap's outer wrapper from <Text> to <Box> and move the prefix into an inner <Text> component.
  3. Apply Option B fix: Modify the inline-code-span renderer to use <Text>-level styling instead of <Box> wrapping.
  4. Test the fix: Reproduce the issue and verify that the crash no longer occurs after applying the chosen fix.

Example

// Option A fix
<Box>
  <Text>※ recap: </Text>
  <InlineMarkdown content={preview}/>
</Box>

// Option B fix
<Text backgroundColor="gray"> {code} </Text>

Notes

The provided fixes assume that the issue is specific to the recap rendering and not a more general problem with message receipt. Additionally, the workaround of banning backticks in teammate spawn prompts is fragile and may not be a reliable long-term solution.

Recommendation

Apply Option B fix, as it is likely more robust and fixes the code-span component regardless of where it's used. This change should prevent the crash and allow the recap to render correctly.

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

claude-code - 💡(How to fix) Fix [BUG] Agent-team teammate pane crashes with "<Box> can't be nested inside <Text>" when ※ recap renders inline markdown code spans [8 comments, 8 participants]