[BUG] Team leader crashes with "getAppState is not a function" when teammate requests tool permission

Resolved 💬 16 comments Opened Apr 17, 2026 by jonleung Closed Apr 17, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report
  • [x] I am using the latest version of Claude Code

Workflow Context

My primary use of agent teams is talking directly with individual teammates — treating each teammate as its own full Claude Code session, as the docs describe ("Each teammate is a full, independent Claude Code session"). I want to be able to direct a teammate, converse with it, paste things into it, hand it nuanced context, and let it ask me for permission when it needs to. That direct teammate-as-collaborator workflow is the main value I get out of teams vs. plain subagents. This bug blocks that workflow end-to-end, because the teammate can't run any permission-gated tool without crashing the lead.

What's Wrong?

This has happened to me twice today (2026-04-17), so it's reproducible rather than a one-off.

When a teammate (spawned via TeamCreate + Agent with team_name) requests permission for a tool use, the team leader's UI crashes with an unhandled error instead of showing the permission prompt.

The teammate's side shows the expected "Waiting for team lead approval" panel, but on the team-leader side the error below is thrown when attempting to render the permission request. The team leader never sees the approval prompt, so the teammate is blocked indefinitely.

Teammate UI (as seen):

Update(~/.claude/agents/companion.md)
  ⎿  Waiting for permission…
╭───────────────────────────────────────────────────────╮
│ ✻  Waiting for team lead approval                     │
│                                                       │
│ ⏺ @companion-v2                                       │
│                                                       │
│ Tool: Edit                                            │
│ Action: A tool for editing files                      │
│                                                       │
│ Permission request sent to team "weave" leader        │
╰───────────────────────────────────────────────────────╯

What Should Happen?

The team leader should see the teammate's tool-use permission request and be able to approve or deny it.

Error Messages/Logs

Stack trace:

ERROR H.toolUseContext.getAppState is not a function. (In 'H.toolUseContext.getAppState()',
     'H.toolUseContext.getAppState' is undefined)

/$bunfs/root/src/entrypoints/cli.js:8231:15642

- <anonymous> (/$bunfs/root/src/entrypoints/cli.js:8231:15642)
- qX (/$bunfs/root/src/entrypoints/cli.js:477:63169)
- sPH (/$bunfs/root/src/entrypoints/cli.js:477:76220)
- ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)
- sPH (/$bunfs/root/src/entrypoints/cli.js:477:76199)
- ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)
- sPH (/$bunfs/root/src/entrypoints/cli.js:477:76199)
- ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)
- sPH (/$bunfs/root/src/entrypoints/cli.js:477:76199)
- ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)

<details>
<summary>Full raw terminal output (including minified source context around line 8231)</summary>

  ERROR H.toolUseContext.getAppState is not a function. (In 'H.toolUseContext.getAppState()',
       'H.toolUseContext.getAppState' is undefined)

 /$bunfs/root/src/entrypoints/cli.js:8231:15642

 8228: ${w.map((uH)=>{let yH=TH[uH.question];if(yH)return`- "${uH.question}"
 8229:   Answer: ${yH}`;return`- "${uH.question}"
 8230:   (No answer provided)`}).join(`
 8231 `)}`;if(G)Q("tengu_ask_user_question_finish_plan_interview",{source:G,questionCount:w.length,isInPlanMode:n,inter
 :   viewPhaseEnabled:n&&cY()});let oH=await xf8(g,i);K(),q.onReject(P_,oH&&oH.length>0?oH:void
     0)},_[44]=g,_[45]=TH,_[46]=i,_[47]=n,_[48]=G,_[49]=K,_[50]=w,_[51]=q,_[52]=vH;else vH=_[52];let
     GH=vH,NH;if(_[53]!==g||_[54]!==i||_[55]!==n||_[56]!==G||_[57]!==K||_[58]!==YH||_[59]!==w||_[60]!==q)NH=async(D_)=>
     {if(G)Q("tengu_ask_user_question_accepted",{source:G,questionCount:w.length,answerCount:Object.keys(D_).length,isI
     nPlanMode:n,interviewPhaseEnabled:n&&cY()});let P_={};for(let yH of w){let
     eH=D_[yH.question],V_=YH[yH.question]?.textInputValue,QH=(eH?yH.options.find((v_)=>v_.label===eH):void
     0)?.preview;if(QH||V_?.trim())P_[yH.question]={...QH&&{preview:QH},...V_?.trim()&&{notes:V_.trim()}}}let
     oH={...q.input,answers:D_,...Object.keys(P_).length>0&&{annotations:P_}},uH=await
     xf8(g,i);K(),q.onAllow(oH,[],void 0,uH&&uH.length>0?uH:void
     0)},_[53]=g,_[54]=i,_[55]=n,_[56]=G,_[57]=K,_[58]=YH,_[59]=w,_[60]=q,_[61]=NH;else NH=_[61];let
     hH=NH,lH;if(_[62]!==TH||_[63]!==v||_[64]!==w.length||_[65]!==_H||_[66]!==hH)lH=(D_,P_,oH,uH)=>{let yH=uH===void
     0?!0:uH,eH,V_=Array.isArray(P_);if(V_)eH=P_.join(", ");else
     if(oH)eH=Object.values(v[D_]??{}).filter(bI5).length>0?`${oH} (Image attached)`:oH;else
     if(P_==="__other__")eH=Object.values(v[D_]??{}).filter(CI5).length>0?"(Image attached)":P_;else eH=P_;let
     bH=w.length===1;if(!V_&&bH&&yH){let QH={...TH,[D_]:eH};hH(QH).catch(zH);return}_H(D_,eH,yH)},_[62]=TH,_[63]=v,_[64
     ]=w.length,_[65]=_H,_[66]=hH,_[67]=lH;else lH=_[67];let X_=lH,W_;if(_[68]!==TH||_[69]!==ZH||_[70]!==hH)W_=function
     (P_){if(P_==="cancel"){ZH();return}if(P_==="submit")hH(TH).catch(zH)},_[68]=TH,_[69]=ZH,_[70]=hH,_[71]=W_;else
     W_=_[71];let SH=W_,gH=JH?(w?.length||1)-1:w?.length||0,tH;if(_[72]!==r||_[73]!==HH)tH=()=>{if(r>0)HH()},_[72]=r,_[
     73]=HH,_[74]=tH;else tH=_[74];let
     y_=tH,T_;if(_[75]!==r||_[76]!==gH||_[77]!==wH)T_=()=>{if(r<gH)wH()},_[75]=r,_[76]=gH,_[77]=wH,_[78]=T_;else
     T_=_[78];let
     h_=T_,rH;if(_[79]!==h_||_[80]!==y_)rH={"tabs:previous":y_,"tabs:next":h_},_[79]=h_,_[80]=y_,_[81]=rH;else
     rH=_[81];let M_=!(AH&&!KH),UH;if(_[82]!==M_)UH={context:"Tabs",isActive:M_},_[82]=M_,_[83]=UH;else
     UH=_[83];if(C8(rH,UH),t){let D_;if(_[84]!==t.question||_[85]!==u)D_=(yH,eH,V_,bH,QH)=>u(t.question,yH,eH,V_,bH,QH)
     ,_[84]=t.question,_[85]=u,_[86]=D_;else D_=_[86];let
     P_;if(_[87]!==t.question||_[88]!==v)P_=v[t.question]??{},_[87]=t.question,_[88]=v,_[89]=P_;else P_=_[89];let
     oH;if(_[90]!==t.question)oH=(yH)=>p(t.question,yH),_[90]=t.question,_[91]=oH;else oH=_[91];let
     uH;if(_[92]!==TH||_[93]!==t||_[94]!==r||_[95]!==R||_[96]!==W||_[97]!==ZH||_[98]!==GH||_[99]!==X_||_[100]!==LH||_[1
     01]!==h_||_[102]!==y_||_[103]!==JH||_[104]!==wH||_[105]!==OH||_[106]!==YH||_[107]!==w||_[108]!==o||_[109]!==D_||_[
     110]!==P_||_[111]!==oH||_[112]!==a)uH=EP.default.createElement(EP.default.Fragment,null,EP.default.createElement(h
     Q7,{question:t,questions:w,currentQuestionIndex:r,answers:TH,questionStates:YH,hideSubmitTab:JH,minContentHeight:R
     ,minContentWidth:W,planFilePath:OH,onUpdateQuestionState:a,onAnswer:X_,onTextInputFocus:o,onCancel:ZH,onSubmit:wH,
     onTabPrev:y_,onTabNext:h_,onRespondToClaude:LH,onFinishPlanInterview:GH,onImagePaste:D_,pastedContents:P_,onRemove
     Image:oH})),_[92]=TH,_[93]=t,_[94]=r,_[95]=R,_[96]=W,_[97]=ZH,_[98]=GH,_[99]=X_,_[100]=LH,_[101]=h_,_[102]=y_,_[10
     3]=JH,_[104]=wH,_[105]=OH,_[106]=YH,_[107]=w,_[108]=o,_[109]=D_,_[110]=P_,_[111]=oH,_[112]=a,_[113]=uH;else
     uH=_[113];return uH}if(KH){let
     D_;if(_[114]!==jH||_[115]!==TH||_[116]!==r||_[117]!==R||_[118]!==SH||_[119]!==w||_[120]!==q.permissionResult)D_=EP
     .default.createElement(EP.default.Fragment,null,EP.default.createElement(SQ7,{questions:w,currentQuestionIndex:r,a
     nswers:TH,allQuestionsAnswered:jH,permissionResult:q.permissionResult,minContentHeight:R,onFinalResponse:SH})),_[1
     14]=jH,_[115]=TH,_[116]=r,_[117]=R,_[118]=SH,_[119]=w,_[120]=q.permissionResult,_[121]=D_;else D_=_[121];return
     D_}return null}function CI5(H){return H.type==="image"}function bI5(H){return H.type==="image"}function
     II5(H){return H.toolPermissionContext.mode}function xI5(H){return H.type==="image"}function uI5(H){return
     Object.values(H)}function mI5(H){return H.preview}async function xf8(H,_){if(H.length===0)return;return
     Promise.all(H.map(async(q)=>{let{block:K}=await ON({data:q.content,mediaType:q.mediaType,limits:_});return
     K}))}var G_6,EP,IQ7=12,VI5=40,SI5=15;var uQ7=Z(()=>{fy();TN();b9();oK();BH();m8();E_();V8();$i_();BfH();WI();qmH()
     ;d_();L9_();bk();d1H();rj();NQ7();EQ7();bQ7();G_6=x(iH(),1),EP=x(MH(),1)});function
     mQ7(H){for(let{pattern:_,warning:q}of pI5)if(_.test(H))return q;return null}var pI5;

[... extensive minified source continues — omitted for brevity; the full dump spans the entire bundle chunk containing the `By` hook shown below ...]

function a0(H){Q("tengu_unary_event",{event:H.event,completion_type:H.completion_type,language_name:await H.metada
     ta.language_name,message_id:H.metadata.message_id,platform:M8.platform,...H.metadata.hasFeedback!==void
     0&&{hasFeedback:H.metadata.hasFeedback}})}var AmH=Z(()=>{E_()});function By(H,_){let
     q=x8(),K=k_6.useRef(null);k_6.useEffect(()=>{if(K.current===H.toolUseID)return;K.current=H.toolUseID,q((T)=>({...T
     ,attribution:{...T.attribution,permissionPromptCount:T.attribution.permissionPromptCount+1}}));let
     O=H.toolUseContext.getAppState().toolPermissionContext.mode;Q("tengu_tool_use_show_permission_request",{messageID:
     H.assistantMessage.message.id,toolName:J7(H.tool.name),isMcp:H.tool.isMcp??!1,decisionReasonType:H.permissionResul
     t.decisionReason?.type,sandboxEnabled:G8.isSandboxingEnabled(),permissionMode:O}),a0({completion_type:_.completion
     _type,event:"response",metadata:{language_name:_.language_name,message_id:H.assistantMessage.message.id,platform:M
     8.platform}})},[H,_,q])}

 - <anonymous> (/$bunfs/root/src/entrypoints/cli.js:8231:15642)
 - qX (/$bunfs/root/src/entrypoints/cli.js:477:63169)
 - sPH (/$bunfs/root/src/entrypoints/cli.js:477:76220)
 - ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)
 - sPH (/$bunfs/root/src/entrypoints/cli.js:477:76199)
 - ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)
 - sPH (/$bunfs/root/src/entrypoints/cli.js:477:76199)
 - ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)
 - sPH (/$bunfs/root/src/entrypoints/cli.js:477:76199)
 - ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)

</details>

Tracing the minified source at cli.js:8231, the crash is in the By hook — the one that fires the tengu_tool_use_show_permission_request telemetry event when a permission prompt is rendered:

function By(H, _) {
  let q = x8(), K = k_6.useRef(null);
  k_6.useEffect(() => {
    if (K.current === H.toolUseID) return;
    K.current = H.toolUseID;
    q((T) => ({ ...T, attribution: { ...T.attribution,
      permissionPromptCount: T.attribution.permissionPromptCount + 1 } }));
    let O = H.toolUseContext.getAppState().toolPermissionContext.mode;  // ← throws here
    Q("tengu_tool_use_show_permission_request", { ... permissionMode: O });
    ...
  }, [H, _, q]);
}

So H.toolUseContext is present but getAppState is undefined on it. Likely cause (guess): when the permission request is forwarded from a teammate to the team leader across the team IPC boundary, toolUseContext is reconstructed from a serialized form that drops method references — so getAppState, which was a closure on the teammate process, doesn't survive the trip to the team-leader side.

Steps to Reproduce

  1. In Claude Code, call TeamCreate to create a team (I used weave).
  2. Call Agent with that team_name set and a name to spawn a teammate (mine: @companion-v2).
  3. Ask the teammate to use a tool that requires permission — something not pre-approved. In my case: Edit ~/.claude/agents/companion.md.
  4. On the teammate side, the "Waiting for team lead approval" panel appears (shown above).
  5. On the team-leader side, the error above is thrown instead of the approval prompt. The teammate is stuck waiting forever.

Workaround: toggle ⏵⏵ bypass permissions mode on the team leader so permission prompts are skipped entirely — but that defeats the purpose of team-level permission gating.

Claude Model

Opus 4.7

Is this a regression?

I don't know

Claude Code Version

2.1.112 (Claude Code)

Platform

Anthropic API

Operating System

macOS (Darwin 25.2.0)

Terminal/Shell

iTerm2 (inside tmux)

Additional Information

This may be tmux-specific — please investigate that angle first. I am running Claude Code inside tmux (on iTerm2), and teams in Claude Code use tmux panes to host teammates. Prior team bugs have turned out to be tmux-specific (e.g. #23527, which hit only when pane-base-index was non-zero; and #24694, which involves the teammate/leader rendering split across tmux panes). It would not surprise me if the toolUseContext being passed to the team leader's By hook is being marshaled across a tmux pane / IPC boundary and losing its getAppState method in the process. If you cannot reproduce outside tmux, that would be a strong signal the bug lives in the tmux-pane-routing path rather than the general team permission flow.

Related existing issues (touch similar flows but none match this exact error):

  • #23527 — Teammate mode fails to deliver instructions when tmux pane-base-index is non-zero (tmux-specific)
  • #24694 — AskUserQuestion tool rendering in teammate pane with no leader notification (tmux teammates)
  • #25254 — Team agents' messages not delivered to team lead in VS Code extension; permission prompts invisible
  • #29293 — Agent Teams: Teammates fail to spawn
  • #30012 — Remote Control does not show permission prompts from agent team sub-panes

View original on GitHub ↗

16 Comments

github-actions[bot] · 3 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/49812
  2. https://github.com/anthropics/claude-code/issues/49381
  3. https://github.com/anthropics/claude-code/issues/49763

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

0xbrainkid · 3 months ago

Team leader crashing with "getAppState is not a function" when a teammate requests tool permission — twice in one day, so reproducible — is a multi-agent session state management bug where the permission request renderer assumes application state that is not present in the team leader's current context.

From an agent team identity and authorization perspective, this crash completely breaks the team authorization model: the teammate correctly enters the "waiting for team lead approval" state, but the team leader never sees the approval prompt because the renderer crashes. The teammate is blocked indefinitely with no path to recovery.

The getAppState is not a function error pattern suggests the permission request UI is attempting to access global application state that either:

  1. Was not initialized in the team leader session context (different initialization path for team leader vs standalone session)
  2. Was garbage collected or out of scope by the time the permission request arrived
  3. Is being accessed via a function that was not defined in the version of the app state module loaded in the team leader context

The fix direction: The permission request renderer must be defensive about the application state it accesses. If getAppState is not available (or throws), the renderer should fall back to a simpler approval UI that does not depend on the full app state.

Workaround while fix is pending: After the team leader crash, kill the team leader process and restart. The teammate's pending permission request will timeout or error, but at least the team leader is functional again. Starting the team from scratch is currently the only recovery path.

For the bug report: The teammate's exact permission request (what tool, what file/action) at the time of crash would help narrow down whether this is specific to certain tool types or universal.

hadrien · 3 months ago

Exact same symptoms here! Occurred twice in less than 2 hours.

Claude Model

Opus 4.7

Is this a regression?

I don't know

Claude Code Version

2.1.112 (Claude Code)

Platform

Anthropic API

Operating System

macOS (Darwin Kernel Version 25.4.0: Thu Mar 19 19:32:59 PDT 2026; root:xnu-12377.101.15~1/RELEASE_ARM64_T8122 arm64 arm Darwin)

Terminal/Shell

iTerm2

Output

<details>
<summary>Raw output on team lead session when it occurs</summary>

 Do you want to make this edit to kubernetes.md?
 ❯ 1. Yes
   2. Yes, allow all edits during this session (shift+tab)
   3. No

 Esc to cancel · Tab to amend

  ERROR  H.toolUseContext.getAppState is not a function. (In 'H.toolUseContext.getAppState()',
        'H.toolUseContext.getAppState' is undefined)

 /$bunfs/root/src/entrypoints/cli.js:8231:15642

 8228: ${w.map((uH)=>{let yH=TH[uH.question];if(yH)return`- "${uH.question}"
 8229:   Answer: ${yH}`;return`- "${uH.question}"
 8230:   (No answer provided)`}).join(`
 8231 `)}`;if(G)Q("tengu_ask_user_question_finish_plan_interview",{source:G,questionCount:w.length,isInP
 :   lanMode:n,interviewPhaseEnabled:n&&cY()});let oH=await
     xf8(g,i);K(),q.onReject(P_,oH&&oH.length>0?oH:void
     0)},_[44]=g,_[45]=TH,_[46]=i,_[47]=n,_[48]=G,_[49]=K,_[50]=w,_[51]=q,_[52]=vH;else vH=_[52];let
     GH=vH,NH;if(_[53]!==g||_[54]!==i||_[55]!==n||_[56]!==G||_[57]!==K||_[58]!==YH||_[59]!==w||_[60]!==q
     )NH=async(D_)=>{if(G)Q("tengu_ask_user_question_accepted",{source:G,questionCount:w.length,answerCo
     unt:Object.keys(D_).length,isInPlanMode:n,interviewPhaseEnabled:n&&cY()});let P_={};for(let yH of
     w){let eH=D_[yH.question],V_=YH[yH.question]?.textInputValue,QH=(eH?yH.options.find((v_)=>v_.label=
     ==eH):void 0)?.preview;if(QH||V_?.trim())P_[yH.question]={...QH&&{preview:QH},...V_?.trim()&&{notes
     :V_.trim()}}}let oH={...q.input,answers:D_,...Object.keys(P_).length>0&&{annotations:P_}},uH=await
     xf8(g,i);K(),q.onAllow(oH,[],void 0,uH&&uH.length>0?uH:void
     0)},_[53]=g,_[54]=i,_[55]=n,_[56]=G,_[57]=K,_[58]=YH,_[59]=w,_[60]=q,_[61]=NH;else NH=_[61];let
     hH=NH,lH;if(_[62]!==TH||_[63]!==v||_[64]!==w.length||_[65]!==_H||_[66]!==hH)lH=(D_,P_,oH,uH)=>{let
     yH=uH===void 0?!0:uH,eH,V_=Array.isArray(P_);if(V_)eH=P_.join(", ");else
     if(oH)eH=Object.values(v[D_]??{}).filter(bI5).length>0?`${oH} (Image attached)`:oH;else
     if(P_==="__other__")eH=Object.values(v[D_]??{}).filter(CI5).length>0?"(Image attached)":P_;else
     eH=P_;let bH=w.length===1;if(!V_&&bH&&yH){let QH={...TH,[D_]:eH};hH(QH).catch(zH);return}_H(D_,eH,y
     H)},_[62]=TH,_[63]=v,_[64]=w.length,_[65]=_H,_[66]=hH,_[67]=lH;else lH=_[67];let
     X_=lH,W_;if(_[68]!==TH||_[69]!==ZH||_[70]!==hH)W_=function(P_){if(P_==="cancel"){ZH();return}if(P_=
     =="submit")hH(TH).catch(zH)},_[68]=TH,_[69]=ZH,_[70]=hH,_[71]=W_;else W_=_[71];let
     SH=W_,gH=JH?(w?.length||1)-1:w?.length||0,tH;if(_[72]!==r||_[73]!==HH)tH=()=>{if(r>0)HH()},_[72]=r,
     _[73]=HH,_[74]=tH;else tH=_[74];let y_=tH,T_;if(_[75]!==r||_[76]!==gH||_[77]!==wH)T_=()=>{if(r<gH)w
     H()},_[75]=r,_[76]=gH,_[77]=wH,_[78]=T_;else T_=_[78];let h_=T_,rH;if(_[79]!==h_||_[80]!==y_)rH={"t
     abs:previous":y_,"tabs:next":h_},_[79]=h_,_[80]=y_,_[81]=rH;else rH=_[81];let
     M_=!(AH&&!KH),UH;if(_[82]!==M_)UH={context:"Tabs",isActive:M_},_[82]=M_,_[83]=UH;else
     UH=_[83];if(C8(rH,UH),t){let D_;if(_[84]!==t.question||_[85]!==u)D_=(yH,eH,V_,bH,QH)=>u(t.question,
     yH,eH,V_,bH,QH),_[84]=t.question,_[85]=u,_[86]=D_;else D_=_[86];let
     P_;if(_[87]!==t.question||_[88]!==v)P_=v[t.question]??{},_[87]=t.question,_[88]=v,_[89]=P_;else
     P_=_[89];let oH;if(_[90]!==t.question)oH=(yH)=>p(t.question,yH),_[90]=t.question,_[91]=oH;else
     oH=_[91];let uH;if(_[92]!==TH||_[93]!==t||_[94]!==r||_[95]!==R||_[96]!==W||_[97]!==ZH||_[98]!==GH||
     _[99]!==X_||_[100]!==LH||_[101]!==h_||_[102]!==y_||_[103]!==JH||_[104]!==wH||_[105]!==OH||_[106]!==
     YH||_[107]!==w||_[108]!==o||_[109]!==D_||_[110]!==P_||_[111]!==oH||_[112]!==a)uH=EP.default.createE
     lement(EP.default.Fragment,null,EP.default.createElement(hQ7,{question:t,questions:w,currentQuestio
     nIndex:r,answers:TH,questionStates:YH,hideSubmitTab:JH,minContentHeight:R,minContentWidth:W,planFil
     ePath:OH,onUpdateQuestionState:a,onAnswer:X_,onTextInputFocus:o,onCancel:ZH,onSubmit:wH,onTabPrev:y
     _,onTabNext:h_,onRespondToClaude:LH,onFinishPlanInterview:GH,onImagePaste:D_,pastedContents:P_,onRe
     moveImage:oH})),_[92]=TH,_[93]=t,_[94]=r,_[95]=R,_[96]=W,_[97]=ZH,_[98]=GH,_[99]=X_,_[100]=LH,_[101
     ]=h_,_[102]=y_,_[103]=JH,_[104]=wH,_[105]=OH,_[106]=YH,_[107]=w,_[108]=o,_[109]=D_,_[110]=P_,_[111]
     =oH,_[112]=a,_[113]=uH;else uH=_[113];return uH}if(KH){let D_;if(_[114]!==jH||_[115]!==TH||_[116]!=
     =r||_[117]!==R||_[118]!==SH||_[119]!==w||_[120]!==q.permissionResult)D_=EP.default.createElement(EP
     .default.Fragment,null,EP.default.createElement(SQ7,{questions:w,currentQuestionIndex:r,answers:TH,
     allQuestionsAnswered:jH,permissionResult:q.permissionResult,minContentHeight:R,onFinalResponse:SH})
     ),_[114]=jH,_[115]=TH,_[116]=r,_[117]=R,_[118]=SH,_[119]=w,_[120]=q.permissionResult,_[121]=D_;else
      D_=_[121];return D_}return null}function CI5(H){return H.type==="image"}function bI5(H){return
     H.type==="image"}function II5(H){return H.toolPermissionContext.mode}function xI5(H){return
     H.type==="image"}function uI5(H){return Object.values(H)}function mI5(H){return H.preview}async
     function xf8(H,_){if(H.length===0)return;return Promise.all(H.map(async(q)=>{let{block:K}=await
     ON({data:q.content,mediaType:q.mediaType,limits:_});return K}))}var G_6,EP,IQ7=12,VI5=40,SI5=15;var
      uQ7=Z(()=>{fy();TN();b9();oK();BH();m8();E_();V8();$i_();BfH();WI();qmH();d_();L9_();bk();d1H();rj
     ();NQ7();EQ7();bQ7();G_6=x(iH(),1),EP=x(MH(),1)});function mQ7(H){for(let{pattern:_,warning:q}of
     pI5)if(_.test(H))return q;return null}var pI5;var
     pQ7=Z(()=>{pI5=[{pattern:/\bgit\s+reset\s+--hard\b/,warning:"Note: may discard uncommitted
     changes"},{pattern:/\bgit\s+push\b[^;&|\n]*[ \t](--force|--force-with-lease|-f)\b/,warning:"Note:
     may overwrite remote history"},{pattern:/\bgit\s+clean\b(?![^;&|\n]*(?:-[a-zA-Z]*n|--dry-run))[^;&|
     \n]*-[a-zA-Z]*f/,warning:"Note: may permanently delete untracked
     files"},{pattern:/\bgit\s+checkout\s+(--\s+)?\.[ \t]*($|[;&|\n])/,warning:"Note: may discard all
     working tree changes"},{pattern:/\bgit\s+restore\s+(--\s+)?\.[ \t]*($|[;&|\n])/,warning:"Note: may
     discard all working tree changes"},{pattern:/\bgit\s+stash[ \t]+(drop|clear)\b/,warning:"Note: may
     permanently remove stashed changes"},{pattern:/\bgit\s+branch\s+(-D[
     \t]|--delete\s+--force|--force\s+--delete)\b/,warning:"Note: may force-delete a
     branch"},{pattern:/\bgit\s+(commit|push|merge)\b[^;&|\n]*--no-verify\b/,warning:"Note: may skip
     safety hooks"},{pattern:/\bgit\s+commit\b[^;&|\n]*--amend\b/,warning:"Note: may rewrite the last
     commit"},{pattern:/(^|[;&|\n]\s*)rm\s+-[a-zA-Z]*[rR][a-zA-Z]*f|(^|[;&|\n]\s*)rm\s+-[a-zA-Z]*f[a-zA-
     Z]*[rR]/,warning:"Note: may recursively force-remove
     files"},{pattern:/(^|[;&|\n]\s*)rm\s+-[a-zA-Z]*[rR]/,warning:"Note: may recursively remove
     files"},{pattern:/(^|[;&|\n]\s*)rm\s+-[a-zA-Z]*f/,warning:"Note: may force-remove
     files"},{pattern:/\b(DROP|TRUNCATE)\s+(TABLE|DATABASE|SCHEMA)\b/i,warning:"Note: may drop or
     truncate database objects"},{pattern:/\bDELETE\s+FROM\s+\w+[ \t]*(;|"|'|\n|$)/i,warning:"Note: may
     delete all rows from a database table"},{pattern:/\bkubectl\s+delete\b/,warning:"Note: may delete
     Kubernetes resources"},{pattern:/\bterraform\s+destroy\b/,warning:"Note: may destroy Terraform
     infrastructure"}]});function mf8(H,_){if(!_?.subcommands?.length)return!1;let
     q=H.toLowerCase();return _.subcommands.some((K)=>Array.isArray(K.name)?K.name.some((O)=>O.toLowerCa
     se()===q):K.name.toLowerCase()===q)}function BQ7(H,_,q){if(q?.options){let
     K=q.options.find((O)=>Array.isArray(O.name)?O.name.includes(H):O.name===H);if(K)return!!K.args}if(q
     ?.subcommands?.length&&_&&!_.startsWith("-"))return!mf8(_,q);return!1}function gI5(H,_){for(let
     q=0;q<H.length;q++){let K=H[q];if(!K)continue;if(K.startsWith("-")){if(BQ7(K,H[q+1],_))q++;continue
     }if(!_?.subcommands?.length)return K;if(mf8(K,_))return K}return}async function Z_6(H,_,q){let
     K=await FI5(H,_,q),O=[H],T=!!q?.subcommands?.length,$=!1;for(let A=0;A<_.length;A++){let
     z=_[A];if(!z||O.length>=K)break;if(z.startsWith("-")){if(z==="-c"&&["python","python3"].includes(H.
     toLowerCase()))break;if(q?.options){let w=q.options.find((Y)=>Array.isArray(Y.name)?Y.name.includes
     (z):Y.name===z);if(w?.args&&TmH(w.args).some((Y)=>Y?.isCommand||Y?.isModule)){O.push(z);continue}}i
     f(T&&!$){if(BQ7(z,_[A+1],q))A++;continue}break}if(await
     UI5(z,_.slice(0,A),q))break;if(T&&!$)$=mf8(z,q);O.push(z)}return O.join(" ")}async function
     FI5(H,_,q){let K=gI5(_,q),O=H.toLowerCase(),T=K?`${O} ${K.toLowerCase()}`:O;if(jPH[T])return
     jPH[T];if(jPH[O])return jPH[O];if(!q)return 2;if(q.options&&_.some(($)=>$?.startsWith("-")))for(let
      $ of _){if(!$?.startsWith("-"))continue;let A=q.options.find((z)=>Array.isArray(z.name)?z.name.inc
     ludes($):z.name===$);if(A?.args&&TmH(A.args).some((z)=>z?.isCommand||z?.isModule))return
     3}if(K&&q.subcommands?.length){let $=K.toLowerCase(),A=q.subcommands.find((z)=>Array.isArray(z.name
     )?z.name.some((w)=>w.toLowerCase()===$):z.name.toLowerCase()===$);if(A){if(A.args){let
     z=TmH(A.args);if(z.some((w)=>w?.isCommand))return 3;if(z.some((w)=>w?.isVariadic))return
     2}if(A.subcommands?.length)return 4;if(!A.args)return 2;return 3}}if(q.args){let $=TmH(q.args);if($
     .some((A)=>A?.isCommand))return!Array.isArray(q.args)&&q.args.isCommand?2:Math.min(2+$.findIndex((A
     )=>A?.isCommand),3);if(!q.subcommands?.length){if($.some((A)=>A?.isVariadic))return
     1;if($[0]&&!$[0].isOptional)return 2}}return
     q.args&&TmH(q.args).some(($)=>$?.isDangerous)?3:2}async function
     UI5(H,_,q){if(H.startsWith("-"))return!0;let K=H.lastIndexOf("."),O=K>0&&K<H.length-1&&!H.substring
     (K+1).includes(":"),T=H.includes("/")||O,$=BI5.some((A)=>H.startsWith(A));if(!T&&!$)return!1;if(q?.
     options&&_.length>0&&_[_.length-1]==="-m"){let A=q.options.find((z)=>Array.isArray(z.name)?z.name.i
     ncludes("-m"):z.name==="-m");if(A?.args&&TmH(A.args).some((z)=>z?.isModule))return!1}return!0}var
     BI5,jPH,TmH=(H)=>Array.isArray(H)?H:[H];var
     pf8=Z(()=>{BI5=["http://","https://","ftp://"],jPH={rg:2,"pre-commit":2,gcloud:4,"gcloud
     compute":6,"gcloud beta":6,aws:4,az:4,kubectl:3,docker:3,dotnet:3,"git push":2}});var dI5,gQ7;var
     FQ7=Z(()=>{dI5={name:"alias",description:"Create or list command
     aliases",args:{name:"definition",description:"Alias definition in the form
     name=value",isOptional:!0,isVariadic:!0}},gQ7=dI5});var cI5,UQ7;var
     dQ7=Z(()=>{cI5={name:"nohup",description:"Run a command immune to
     hangups",args:{name:"command",description:"Command to run with nohup",isCommand:!0}},UQ7=cI5});var
     cQ7;var QQ7=Z(()=>{cQ7={name:"pyright",description:"Type checker for
     Python",options:[{name:["--help","-h"],description:"Show help
     message"},{name:"--version",description:"Print pyright version and
     exit"},{name:["--watch","-w"],description:"Continue to run and watch for
     changes"},{name:["--project","-p"],description:"Use the configuration file at this
     location",args:{name:"FILE OR DIRECTORY"}},{name:"-",description:"Read file or directory list from
     stdin"},{name:"--createstub",description:"Create type stub file(s) for
     import",args:{name:"IMPORT"}},{name:["--typeshedpath","-t"],description:"Use typeshed type stubs at
      this location",args:{name:"DIRECTORY"}},{name:"--verifytypes",description:"Verify completeness of
     types in py.typed package",args:{name:"IMPORT"}},{name:"--ignoreexternal",description:"Ignore
     external imports for --verifytypes"},{name:"--pythonpath",description:"Path to the Python
     interpreter",args:{name:"FILE"}},{name:"--pythonplatform",description:"Analyze for
     platform",args:{name:"PLATFORM"}},{name:"--pythonversion",description:"Analyze for Python
     version",args:{name:"VERSION"}},{name:["--venvpath","-v"],description:"Directory that contains
     virtual environments",args:{name:"DIRECTORY"}},{name:"--outputjson",description:"Output results in
     JSON format"},{name:"--verbose",description:"Emit verbose
     diagnostics"},{name:"--stats",description:"Print detailed performance
     stats"},{name:"--dependencies",description:"Emit import dependency
     information"},{name:"--level",description:"Minimum diagnostic
     level",args:{name:"LEVEL"}},{name:"--skipunannotated",description:"Skip type analysis of
     unannotated functions"},{name:"--warnings",description:"Use exit code of 1 if warnings are
     reported"},{name:"--threads",description:"Use up to N threads to parallelize type
     checking",args:{name:"N",isOptional:!0}}],args:{name:"files",description:"Specify files or
     directories to analyze (overrides config file)",isVariadic:!0,isOptional:!0}}});var QI5,lQ7;var
     nQ7=Z(()=>{QI5={name:"sleep",description:"Delay for a specified amount of
     time",args:{name:"duration",description:"Duration to sleep (seconds or with suffix like 5s, 2m,
     1h)",isOptional:!1}},lQ7=QI5});var lI5,iQ7;var rQ7=Z(()=>{lI5={name:"srun",description:"Run a
     command on SLURM cluster nodes",options:[{name:["-n","--ntasks"],description:"Number of
     tasks",args:{name:"count",description:"Number of tasks to
     run"}},{name:["-N","--nodes"],description:"Number of nodes",args:{name:"count",description:"Number
     of nodes to allocate"}}],args:{name:"command",description:"Command to run on the
     cluster",isCommand:!0}},iQ7=lI5});var nI5,oQ7;var aQ7=Z(()=>{nI5={name:"time",description:"Time a
     command",args:{name:"command",description:"Command to time",isCommand:!0}},oQ7=nI5});var
     iI5,sQ7;var tQ7=Z(()=>{iI5={name:"timeout",description:"Run a command with a time
     limit",args:[{name:"duration",description:"Duration to wait before timing out (e.g., 10, 5s,
     2m)",isOptional:!1},{name:"command",description:"Command to run",isCommand:!0}]},sQ7=iI5});var
     Bf8;var
     eQ7=Z(()=>{FQ7();dQ7();QQ7();nQ7();rQ7();aQ7();tQ7();Bf8=[cQ7,sQ7,lQ7,gQ7,UQ7,oQ7,iQ7]});async
     function rI5(H){if(!H||H.includes("/")||H.includes("\\"))return null;if(H.includes(".."))return
     null;if(H.startsWith("-")&&H!=="-")return null;try{let _=await
     import(`@withfig/autocomplete/build/${H}.js`);return _.default||_}catch{return null}}var $mH;var
     gf8=Z(()=>{vm();eQ7();$mH=hM(async(H)=>{return Bf8.find((q)=>q.name===H)||await
     rI5(H)||null},(H)=>H)});function sI5(H,_){if(!_?.subcommands?.length)return!1;return
     _.subcommands.some((q)=>Array.isArray(q.name)?q.name.includes(H):q.name===H)}async function
     L_6(H,_=0,q=0){if(q>2||_>10)return null;let K=await AB6(H);if(!K)return
     null;if(!K.commandNode)return{commandPrefix:null};let{envVars:O,commandNode:T}=K,$=WsH(T),[A,...z]=
     $;if(!A)return{commandPrefix:null};let w=await
     $mH(A),Y=aI5.has(A)||w?.args&&_l7(w.args).some((D)=>D?.isCommand);if(Y&&z[0]&&sI5(z[0],w))Y=!1;let
     f=Y?await tI5(A,z,_,q):await Z_6(A,z,w);if(f===null&&_===0&&Y)return null;let
     j=O.length?`${O.join(" ")} `:"";return{commandPrefix:f?j+f:null}}async function tI5(H,_,q,K){let
     O=await $mH(H);if(O?.args){let A=_l7(O.args).findIndex((z)=>z?.isCommand);if(A!==-1){let
     z=[H];for(let w=0;w<_.length&&w<=A;w++)if(w===A){let Y=await L_6(_.slice(w).join("
     "),q+1,K+1);if(Y?.commandPrefix)return z.push(...Y.commandPrefix.split(" ")),z.join(" ");break}else
      if(_[w]&&!_[w].startsWith("-")&&!Hl7.test(_[w]))z.push(_[w])}}let
     T=_.find((A)=>!A.startsWith("-")&&!oI5.test(A)&&!Hl7.test(A));if(!T)return H;let $=await
     L_6(_.slice(_.indexOf(T)).join(" "),q+1,K+1);return!$?.commandPrefix?null:`${H}
     ${$.commandPrefix}`}async function ql7(H,_){let q=R$(H);if(q.length<=1){let $=await L_6(H);return
     $?.commandPrefix?[$.commandPrefix]:[]}let K=[];for(let $ of q){let
     A=$.trim();if(_?.(A))continue;let z=await
     L_6(A);if(z?.commandPrefix)K.push(z.commandPrefix)}if(K.length===0)return[];let O=new Map;for(let $
      of K){let A=$.split(" ")[0],z=O.get(A);if(z)z.push($);else O.set(A,[$])}let T=[];for(let[,$]of
     O)T.push(eI5($));return T}function eI5(H){if(H.length===0)return"";if(H.length===1)return H[0];let
     q=H[0].split(" "),K=q.length;for(let O=1;O<H.length;O++){let T=H[O].split("
     "),$=0;while($<K&&$<T.length&&q[$]===T[$])$++;K=$}return q.slice(0,Math.max(1,K)).join(" ")}var
     oI5,Hl7,aI5,_l7=(H)=>Array.isArray(H)?H:[H];var
     Kl7=Z(()=>{pf8();FX();UwH();gf8();oI5=/^\d+$/,Hl7=/^[A-Za-z_][A-Za-z0-9_]*=/,aI5=new
     Set(["nice"])});async function
     a0(H){Q("tengu_unary_event",{event:H.event,completion_type:H.completion_type,language_name:await
     H.metadata.language_name,message_id:H.metadata.message_id,platform:H.metadata.platform,...H.metadat
     a.hasFeedback!==void 0&&{hasFeedback:H.metadata.hasFeedback}})}var AmH=Z(()=>{E_()});function
     By(H,_){let q=x8(),K=k_6.useRef(null);k_6.useEffect(()=>{if(K.current===H.toolUseID)return;K.curren
     t=H.toolUseID,q((T)=>({...T,attribution:{...T.attribution,permissionPromptCount:T.attribution.permi
     ssionPromptCount+1}}));let
     O=H.toolUseContext.getAppState().toolPermissionContext.mode;Q("tengu_tool_use_show_permission_reque
     st",{messageID:H.assistantMessage.message.id,toolName:J7(H.tool.name),isMcp:H.tool.isMcp??!1,decisi
     onReasonType:H.permissionResult.decisionReason?.type,sandboxEnabled:G8.isSandboxingEnabled(),permis
     sionMode:O}),a0({completion_type:_.completion_type,event:"response",metadata:{language_name:_.langu
     age_name,message_id:H.assistantMessage.message.id,platform:M8.platform}})},[H,_,q])}var k_6;var
     G3H=Z(()=>{E_();QA();hW();FX();Sf();DR();SO();V8();v5();e_();AmH();k_6=x(MH(),1)});function
     Ol7(H){if(H.type==="classifier")return`${q_.bold(H.classifier)} classifier:
     ${H.reason}`;switch(H.type){case"rule":return`${q_.bold(u1(H.rule.ruleValue))} rule from
     ${Aj_(H.rule.source)}`;case"mode":return`${kr(H.mode)} mode`;case"sandboxOverride":return"Requires
     permission to bypass sandbox";case"workingDir":return H.reason;case"safetyCheck":case"other":return
      H.reason;case"permissionPromptTool":return`${q_.bold(H.permissionPromptToolName)} permission
     prompt tool`;case"hook":return H.reason?`${q_.bold(H.hookName)} hook:
     ${H.reason}`:`${q_.bold(H.hookName)} hook`;case"asyncAgent":return
     H.reason;default:return""}}function _x5(H){let _=T3_.c(10),{title:q,decisionReason:K}=H,[O]=Lq(),T;
     if(_[0]!==K||_[1]!==O)T=function(){switch(K.type){case"subcommandResults":return
     C7.default.createElement(m,{flexDirection:"column"},Array.from(K.reasons.entries()).map((f)=>{let[j
     ,D]=f,M=D.behavior==="allow"?i8("success",O)(sH.tick):i8("error",O)(sH.cross);return
     C7.default.createElement(m,{flexDirection:"column",key:j},C7.default.createElement(L,null,M,"
     ",j),D.decisionReason!==void 0&&D.decisionReason.type!=="subcommandResults"&&C7.default.createEleme
     nt(L,null,C7.default.createElement(L,{dimColor:!0},"  ","\u23BF","
     "),C7.default.createElement(kK,null,Ol7(D.decisionReason))),D.behavior==="ask"&&C7.default.createEl
     ement(qx5,{suggestions:D.suggestions}))}));default:return C7.default.createElement(L,null,C7.defaul
     t.createElement(kK,null,Ol7(K)))}},_[0]=K,_[1]=O,_[2]=T;else T=_[2];let
     $=T,A;if(_[3]!==q)A=q&&C7.default.createElement(L,null,q),_[3]=q,_[4]=A;else A=_[4];let
     z;if(_[5]!==$)z=$(),_[5]=$,_[6]=z;else z=_[6];let w;if(_[7]!==A||_[8]!==z)w=C7.default.createElemen
     t(m,{flexDirection:"column"},A,z),_[7]=A,_[8]=z,_[9]=w;else w=_[9];return w}function qx5(H){let
     _=T3_.c(18),{suggestions:q}=H,K,O,T,$,A,z,w;if(_[0]!==q){w=Symbol.for("react.early_return_sentinel"
     );H:{let j=Nc(q);if(j.length===0){w=null;break H}if(O=L,_[8]===Symbol.for("react.memo_cache_sentine
     l"))$=C7.default.createElement(L,{dimColor:!0},"  ","\u23BF","  "),_[8]=$;else $=_[8];A="Suggested
     rules:",z=" ",K=kK,T=j.map(Kx5).join(",
     ")}_[0]=q,_[1]=K,_[2]=O,_[3]=T,_[4]=$,_[5]=A,_[6]=z,_[7]=w}else K=_[1],O=_[2],T=_[3],$=_[4],A=_[5],
     z=_[6],w=_[7];if(w!==Symbol.for("react.early_return_sentinel"))return w;let
     Y;if(_[9]!==K||_[10]!==T)Y=C7.default.createElement(K,null,T),_[9]=K,_[10]=T,_[11]=Y;else
     Y=_[11];let f;if(_[12]!==O||_[13]!==$||_[14]!==A||_[15]!==z||_[16]!==Y)f=C7.default.createElement(O
     ,null,$,A,z,Y),_[12]=O,_[13]=$,_[14]=A,_[15]=z,_[16]=Y,_[17]=f;else f=_[17];return f}function
     Kx5(H){return q_.bold(u1(H))}function Ox5(H){if(!H)return[];return
     H.flatMap((_)=>{switch(_.type){case"addDirectories":return
     _.directories;default:return[]}})}function Tx5(H){if(!H)return;let
     _=H.findLast((q)=>q.type==="setMode");return _?.type==="setMode"?_.mode:void 0}function $x5(H){let
     _=T3_.c(22),{suggestions:q,width:K}=H;if(!q||q.length===0){let $;if(_[0]===Symbol.for("react.memo_c
     ache_sentinel"))$=C7.default.createElement(L,{dimColor:!0},"Suggestions "),_[0]=$;else $=_[0];let
     A;if(_[1]!==K)A=C7.default.createElement(m,{justifyContent:"flex-end",minWidth:K},$),_[1]=K,_[2]=A;
     else A=_[2];let z;if(_[3]===Symbol.for("react.memo_cache_sentinel"))z=C7.default.createElement(L,nu
     ll,"None"),_[3]=z;else z=_[3];let
     w;if(_[4]!==A)w=C7.default.createElement(m,{flexDirection:"row"},A,z),_[4]=A,_[5]=w;else
     w=_[5];return w}let O,T;if(_[6]!==q||_[7]!==K){T=Symbol.for("react.early_return_sentinel");H:{let
     $=Nc(q),A=Ox5(q),z=Tx5(q);if($.length===0&&A.length===0&&!z){let D;if(_[10]===Symbol.for("react.mem
     o_cache_sentinel"))D=C7.default.createElement(L,{dimColor:!0},"Suggestion "),_[10]=D;else
     D=_[10];let M;if(_[11]!==K)M=C7.default.createElement(m,{justifyContent:"flex-end",minWidth:K},D),_
     [11]=K,_[12]=M;else M=_[12];let J;if(_[13]===Symbol.for("react.memo_cache_sentinel"))J=C7.default.c
     reateElement(L,null,"None"),_[13]=J;else J=_[13];let
     P;if(_[14]!==M)P=C7.default.createElement(m,{flexDirection:"row"},M,J),_[14]=M,_[15]=P;else
     P=_[15];T=P;break H}let w;if(_[16]===Symbol.for("react.memo_cache_sentinel"))w=C7.default.createEle
     ment(L,{dimColor:!0},"Suggestions "),_[16]=w;else w=_[16];let Y;if(_[17]!==K)Y=C7.default.createEle
     ment(m,{justifyContent:"flex-end",minWidth:K},w),_[17]=K,_[18]=Y;else Y=_[18];let
     f;if(_[19]===Symbol.for("react.memo_cache_sentinel"))f=C7.default.createElement(L,null,"
     "),_[19]=f;else f=_[19];let
     j;if(_[20]!==Y)j=C7.default.createElement(m,{flexDirection:"row"},Y,f),_[20]=Y,_[21]=j;else
     j=_[21];O=C7.default.createElement(m,{flexDirection:"column"},j,$.length>0&&C7.default.createElemen
     t(m,{flexDirection:"row"},C7.default.createElement(m,{justifyContent:"flex-end",minWidth:K},C7.defa
     ult.createElement(L,{dimColor:!0}," Rules ")),C7.default.createElement(m,{flexDirection:"column"},$
     .map(zx5))),A.length>0&&C7.default.createElement(m,{flexDirection:"row"},C7.default.createElement(m
     ,{justifyContent:"flex-end",minWidth:K},C7.default.createElement(L,{dimColor:!0}," Directories
     ")),C7.default.createElement(m,{flexDirection:"column"},A.map(Ax5))),z&&C7.default.createElement(m,
     {flexDirection:"row"},C7.default.createElement(m,{justifyContent:"flex-end",minWidth:K},C7.default.
     createElement(L,{dimColor:!0}," Mode
     ")),C7.default.createElement(L,null,kr(z))))}_[6]=q,_[7]=K,_[8]=O,_[9]=T}else
     O=_[8],T=_[9];if(T!==Symbol.for("react.early_return_sentinel"))return T;return O}function
     Ax5(H,_){return C7.default.createElement(L,{key:_},sH.bullet," ",H)}function zx5(H,_){return
     C7.default.createElement(L,{key:_},sH.bullet," ",u1(H))}function v_6(H){let
     _=T3_.c(25),{permissionResult:q,toolName:K}=H,O=f_(Yx5),T=q.decisionReason,$="suggestions"in
     q?q.suggestions:void 0,A;if(_[0]!==$||_[1]!==K||_[2]!==O){H:{let
     X=G8.isSandboxingEnabled()&&G8.isAutoAllowBashIfSandboxedEnabled(),R=XxH(O,{sandboxAutoAllowEnabled
     :X}),W=Nc($);if(W.length>0){A=R.filter((G)=>W.some((k)=>k.toolName===G.rule.ruleValue.toolName&&k.r
     uleContent===G.rule.ruleValue.ruleContent));break H}if(K){let
     G;if(_[4]!==K)G=(k)=>k.rule.ruleValue.toolName===K,_[4]=K,_[5]=G;else G=_[5];A=R.filter(G);break
     H}A=R}_[0]=$,_[1]=K,_[2]=O,_[3]=A}else A=_[3];let
     z=A,w;if(_[6]===Symbol.for("react.memo_cache_sentinel"))w=C7.default.createElement(m,{justifyConten
     t:"flex-end",minWidth:10},C7.default.createElement(L,{dimColor:!0},"Behavior ")),_[6]=w;else
     w=_[6];let Y;if(_[7]!==q.behavior)Y=C7.default.createElement(m,{flexDirection:"row"},w,C7.default.c
     reateElement(L,null,q.behavior)),_[7]=q.behavior,_[8]=Y;else Y=_[8];let
     f;if(_[9]!==q.behavior||_[10]!==q.message)f=q.behavior!=="allow"&&C7.default.createElement(m,{flexD
     irection:"row"},C7.default.createElement(m,{justifyContent:"flex-end",minWidth:10},C7.default.creat
     eElement(L,{dimColor:!0},"Message
     ")),C7.default.createElement(L,null,q.message)),_[9]=q.behavior,_[10]=q.message,_[11]=f;else
     f=_[11];let j;if(_[12]===Symbol.for("react.memo_cache_sentinel"))j=C7.default.createElement(m,{just
     ifyContent:"flex-end",minWidth:10},C7.default.createElement(L,{dimColor:!0},"Reason
     ")),_[12]=j;else j=_[12];let
     D;if(_[13]!==T)D=C7.default.createElement(m,{flexDirection:"row"},j,T===void 0?C7.default.createEle
     ment(L,null,"undefined"):C7.default.createElement(_x5,{decisionReason:T})),_[13]=T,_[14]=D;else
     D=_[14];let
     M;if(_[15]!==$)M=C7.default.createElement($x5,{suggestions:$,width:10}),_[15]=$,_[16]=M;else
     M=_[16];let J;if(_[17]!==z)J=z.length>0&&C7.default.createElement(m,{flexDirection:"column",marginT
     op:1},C7.default.createElement(L,{color:"warning"},sH.warning," Unreachable Rules
     (",z.length,")"),z.map(wx5)),_[17]=z,_[18]=J;else J=_[18];let
     P;if(_[19]!==Y||_[20]!==f||_[21]!==D||_[22]!==M||_[23]!==J)P=C7.default.createElement(m,{flexDirect
     ion:"column"},Y,f,D,M,J),_[19]=Y,_[20]=f,_[21]=D,_[22]=M,_[23]=J,_[24]=P;else P=_[24];return
     P}function wx5(H,_){return
     C7.default.createElement(m,{key:_,flexDirection:"column",marginLeft:2},C7.default.createElement(L,{
     color:"warning"},u1(H.rule.ruleValue)),C7.default.createElement(L,{dimColor:!0},"
     ",H.reason),C7.default.createElement(L,{dimColor:!0},"  ","Fix: ",H.fix))}function Yx5(H){return
     H.toolPermissionContext}var T3_,C7;var
     Ff8=Z(()=>{$4();cq();BH();V8();EJ();Sf();DR();Ps_();SO();tO();T3_=x(iH(),1),C7=x(MH(),1)});function
      Wx5(H){if(typeof H==="string")return H;try{return xH(H,null,2)}catch{return String(H)}}function
     Rx5(H,_=1000){let q=H.filter((T)=>T.type==="assistant").slice(-3),K=[],O=0;for(let T of
     q.reverse()){let $=T.message.content.filter((A)=>A.type==="text").map((A)=>("text"in
     A)?A.text:"").join(" ");if($&&O<_){let
     A=_-O,z=$.length>A?$.slice(0,A)+"...":$;K.unshift(z),O+=z.length}}return K.join(`





 8232:
 8233: `)}function Uf8(){return w_().permissionExplainerEnabled!==!1}async function
      Tl7({toolName:H,toolInput:_,toolDescription:q,messages:K,signal:O}){if(!Uf8())return null;let
      T=Date.now();try{let $=Wx5(_),A=K?.length?Rx5(K):"",z=`Tool: ${H}
 8234: ${q?`Description: ${q}

 - <anonymous> (/$bunfs/root/src/entrypoints/cli.js:8231:15642)
 - qX (/$bunfs/root/src/entrypoints/cli.js:477:63169)
 - sPH (/$bunfs/root/src/entrypoints/cli.js:477:76220)
 - ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)
 - sPH (/$bunfs/root/src/entrypoints/cli.js:477:76199)
 - ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)
 - sPH (/$bunfs/root/src/entrypoints/cli.js:477:76199)
 - ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)
 - sPH (/$bunfs/root/src/entrypoints/cli.js:477:76199)
 - ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)

</details>

hadrien · 3 months ago

Just occurred with team lead on Opus 4.6 FYI

cleong110 · 3 months ago

Just happened to me. Sonnet 4.5 team lead. Claude Code v2.1.112.

Here's some of the error output, couldn't capture the whole thing very easily from Tmux:

     uggestions:f,width:10}),$[15]=f,$[16]=J;else J=$[16];let 
     X;if($[17]!==Y)X=Y.length>0&&R7.default.createElement(m,{fle
     xDirection:"column",marginTop:1},R7.default.createElement(T,
     {color:"warning"},sH.warning," Unreachable Rules 
     (",Y.length,")"),Y.map(rb1)),$[17]=Y,$[18]=X;else 
     X=$[18];let 
     L;if($[19]!==w||$[20]!==M||$[21]!==j||$[22]!==J||$[23]!==X)L
     =R7.default.createElement(m,{flexDirection:"column"},w,M,j,J
     ,X),$[19]=w,$[20]=M,$[21]=j,$[22]=J,$[23]=X,$[24]=L;else 
     L=$[24];return L}function rb1(H,$){return 
     R7.default.createElement(m,{key:$,flexDirection:"column",mar
     ginLeft:2},R7.default.createElement(T,{color:"warning"},x9(H
     .rule.ruleValue)),R7.default.createElement(T,{dimColor:!0},"
       ",H.reason),R7.default.createElement(T,{dimColor:!0},"  
     ","Fix: ",H.fix))}function ob1(H){return 
     H.toolPermissionContext}var f5$,R7;var 
     gM6=v(()=>{f4();cq();BH();h6();IX();SM();DG();js$();SA();tA(
     );f5$=x(iH(),1),R7=x(JH(),1)});function Kx1(H){if(typeof 
     H==="string")return H;try{return xH(H,null,2)}catch{return 
     String(H)}}function _x1(H,$=1000){let q=H.filter((A)=>A.type
     ==="assistant").slice(-3),K=[],_=0;for(let A of 
     q.reverse()){let f=A.message.content.filter((z)=>z.type==="t
     ext").map((z)=>("text"in z)?z.text:"").join(" 
     ");if(f&&_<$){let z=$-_,Y=f.length>z?f.slice(0,z)+"...":f;K.
     unshift(Y),_+=Y.length}}return K.join(`




 8234:
 8235 `)}function UM6(){return
 :   O$().permissionExplainerEnabled!==!1}async function
     oQ7({toolName:H,toolInput:$,toolDescription:q,messages:K,sig
     nal:_}){if(!UM6())return null;let A=Date.now();try{let
     f=Kx1($),z=K?.length?_x1(K):"",Y=`Tool: ${H}
 8236: ${q?`Description: ${q}

 - <anonymous> (/$bunfs/root/src/entrypoints/cli.js:8233:15642)
 - $2 (/$bunfs/root/src/entrypoints/cli.js:477:63169)
 - aLH (/$bunfs/root/src/entrypoints/cli.js:477:76220)
 - rV (/$bunfs/root/src/entrypoints/cli.js:477:76101)
 - aLH (/$bunfs/root/src/entrypoints/cli.js:477:76199)
 - rV (/$bunfs/root/src/entrypoints/cli.js:477:76101)
 - aLH (/$bunfs/root/src/entrypoints/cli.js:477:76199)
 - rV (/$bunfs/root/src/entrypoints/cli.js:477:76101)
 - aLH (/$bunfs/root/src/entrypoints/cli.js:477:76199)
 - rV (/$bunfs/root/src/entrypoints/cli.js:477:76101)

The team member command that triggered it:

cd (another repo path on the same filesystem) && git branch -a
Oliver-Johnson · 3 months ago

Happened to me too:

Reproduceable: every sub agent permission request triggers it. Team lead completely crashes and I have to restart the claude docker container.
Model: Sonnet 4.6 (team lead and agent)
OS: Ubuntu 24 LTS
Version: Claude Code 2.1.112 AND 2.1.111
Using tmux so difficult to capture much detail.

Error message:

ERROR  q.toolUseContext.getAppState is not a function

 file:///usr/local/lib/node_modules/@anthropic-ai/claude-co
 de/cli.js:8493:15619

 -(file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:8493:15619)
 -S0 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:551:63170)
 -G06 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:551:76223)
 -yN (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:551:76103)
 -G06 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:551:76202)
 -yN (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:551:76103)
 -G06 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:551:76202)
 -yN (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:551:76103)
 -G06 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:551:76202)
 -yN (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:551:76103)

Reverting to 2.1.111 until fixed
Edit also present in 2.1.111

cleong110 · 3 months ago

More debugging:

  • restarted claude code with a new session.
  • Got the team lead to spawn an agent to do cd (another repo path on the same filesystem) && git branch -a, crash.
  • Started it again, had the team lead try running the command itself, no crash, permission request received no problem.
  • At some point the team lead stopped getting messages including permission requests, and started checking the json directly.
  • Started fresh with TeamDelete and new team with new name.
  • Deliberately triggered permission request not on allowlist (rm -rf a tmp file)
  • ERROR H.toolUseContext.getAppState is not a function. (In 'H.toolUseContext.getAppState()', 'H.toolUseContext.getAppState' is undefined)
cleong110 · 3 months ago

Used Claude Code to investigate Claude Code crash, of course 😆. Went a number of rounds, trying to track this down and confirm what was going on, checked it over, as far as I can tell the following is accurate:

Agent Teams Permission Dialog Crash - Bug Report

Environment:

  • Claude Code v2.1.112
  • AWS Bedrock backend
  • Linux environment

Issue: Permission dialogs for spawned agents crash with H.toolUseContext.getAppState is not a function

---

Summary

When a spawned agent requests permission for a Bash command not on the allowlist, the permission dialog appears in the user's UI but immediately crashes with a JavaScript error. This prevents any agent team workflows that require user approval of commands.

Error: H.toolUseContext.getAppState is not a function. (In 'H.toolUseContext.getAppState()', 'H.toolUseContext.getAppState' is undefined)

---

Reproduction Steps

Minimal Test Case

  1. Create a team:
TeamCreate(team_name="test-team", description="Bug reproduction")
  1. Spawn a general-purpose agent:
Agent(
  name="test-agent",
  team_name="test-team",
  model="sonnet",
  subagent_type="general-purpose",
  prompt="Run this command: rm -rf /tmp/test-file-12345"
)
  1. Observe:
  • Agent requests permission
  • Permission dialog appears: "Do you want to proceed? 1. Yes 2. No"
  • Immediate crash with H.toolUseContext.getAppState is not a function

---

What We Tested

1. Team Lifecycle ✅

  • TeamCreate, TeamDelete work correctly
  • Team config files persist properly

2. Agent Spawning ✅

Successfully spawned multiple agent types:

  • general-purpose agents
  • Explore agents (read-only)

All agents spawned successfully with processes running and tmux panes created.

3. Agent Execution ✅

Agents execute tasks correctly:

  • Read files successfully
  • Use Glob/Grep/Read tools
  • Generate reports and responses
  • Send messages to team-lead

4. Message Delivery ✅ (Post-Restart)

After a full CLI restart (exit and --resume):

  • Agent messages delivered correctly via <teammate-message> tags
  • Idle notifications work
  • No message delivery issues

5. Permission Requests for Team-Lead ✅

When team-lead (main session) requests Bash permission:

  • ✅ User sees permission dialog
  • ✅ User can approve/deny
  • ✅ Commands execute successfully
  • ✅ No crash

6. Permission Requests for Spawned Agents ❌

When spawned agent requests Bash permission:

  • ✅ Permission request sent by agent
  • ✅ Permission dialog appears in user UI
  • CRASH when dialog renders or user tries to interact

---

Detailed Crash Information

Agent Side (Agent's tmux window)

@team-lead❯ Test destructive command

● I'll run that destructive command to test the permission system.

  Bash(rm -rf /tmp/test-file-12345)
  ⎿  Waiting for permission…
╭─────────────────────────────────────────────────────────╮
│ ✻  Waiting for team lead approval                       │
│                                                         │
│ ● @test-agent                                           │
│                                                         │
│ Tool: Bash                                              │
│ Action: Remove test file (destructive operation)        │
│                                                         │
│ Permission request sent to team "test-team" leader      │
╰─────────────────────────────────────────────────────────╯

Agent correctly:

  • Recognizes permission needed
  • Sends request to team leader
  • Displays "Waiting for team lead approval"
  • Blocks execution

Team-Lead Side (User's main window)

─────────────────────────────────────────────────────────
 Bash command · @test-agent
 
   rm -rf /tmp/test-file-12345
   Remove test file (destructive operation)
 
 Do you want to proceed?
 ❯ 1. Yes
   2. No
 
 Esc to cancel · Tab to amend · ctrl+e to explain
 
  ERROR  H.toolUseContext.getAppState is not a function

Dialog appears correctly but crashes immediately.

Full Error Trace

ERROR  H.toolUseContext.getAppState is not a function. 
       (In 'H.toolUseContext.getAppState()', 
       'H.toolUseContext.getAppState' is undefined)

/$bunfs/root/src/entrypoints/cli.js:8233:15642

Stack:
- <anonymous> (/$bunfs/root/src/entrypoints/cli.js:8233:15642)
- $2 (/$bunfs/root/src/entrypoints/cli.js:477:63169)
- aLH (/$bunfs/root/src/entrypoints/cli.js:477:76220)
- rV (/$bunfs/root/src/entrypoints/cli.js:477:76101)
- [additional stack frames...]

Error Location:

  • Bundle: /$bunfs/root/src/entrypoints/cli.js:8233:15642
  • Context: Permission explainer/approval flow
  • Issue: toolUseContext object exists but getAppState method is undefined

---

Key Findings

What Works ✅

  1. Team creation/deletion
  2. Agent spawning (all types)
  3. Agent task execution
  4. Agent message sending/receiving (post-restart)
  5. Read-only operations (Glob, Grep, Read)
  6. Team-lead → user permission requests

What's Broken ❌

Spawned agent → user permission dialog interaction crashes

The bug is NOT:

  • ❌ Message delivery (works correctly)
  • ❌ Permission request propagation (requests reach user)
  • ❌ Agent spawning or execution (works correctly)

The bug IS:

  • ✅ Permission dialog crashes when rendered for spawned agents
  • ✅ Error: toolUseContext.getAppState method missing

---

Root Cause

THE BUG: Permission dialog interaction for spawned agents crashes with H.toolUseContext.getAppState is not a function

The Flow:

  1. ✅ Agent requests permission (agent correctly sends request)
  2. ✅ Permission request propagates to user (dialog appears with Yes/No)
  3. CRASH when dialog renders (toolUseContext method missing)

Why Some Commands "Worked":
Commands on the permission allowlist (git, cd, ls, grep, etc.) execute without prompting. The crash only occurs when:

  • Command is NOT on allowlist
  • Permission dialog must be shown
  • Dialog attempts to call toolUseContext.getAppState()

Example allowlist patterns (from ~/.claude/settings.json):

{
  "permissions": {
    "allow": [
      "Bash(git:*)",
      "Bash(cd:*)",
      "Bash(ls:*)",
      "Bash(*&&*git*)",
      "Read(*)",
      "Write(*)"
    ]
  }
}

Impact:

  • Agents can only execute pre-approved allowlist commands
  • Any command requiring user permission crashes the session
  • Effectively blocks agents from implementation work requiring Bash approval

---

Environment Details

  • OS: Linux
  • Claude Code: v2.1.112
  • Backend: AWS Bedrock
  • Environment variables:
  • CLAUDECODE=1
  • CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
  • CLAUDE_CODE_USE_BEDROCK=1

Agent Spawn Command Pattern:

env CLAUDECODE=1 \
    CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 \
    CLAUDE_CODE_USE_BEDROCK=1 \
    /path/to/claude --agent-id agent@team \
                    --agent-name agent \
                    --team-name team \
                    --agent-color blue \
                    --parent-session-id <uuid> \
                    --agent-type general-purpose \
                    --model sonnet

---

Workaround (Temporary)

Until fixed, agents can only use:

  1. Read-only tools (Glob, Grep, Read) - no Bash needed
  2. Pre-approved Bash commands on the allowlist
  3. Explore agents for research tasks (limited tool access)

To expand allowlist, add patterns to ~/.claude/settings.json:

{
  "permissions": {
    "allow": [
      "Bash(command:*)",
      "Bash(*pattern*)"
    ]
  }
}

But this only helps if you know which commands the agent will need in advance.

---

Session Restart Observations

We observed that a full CLI restart (exit and --resume) improved message delivery:

Before restart:

  • Agent messages stuck in inbox file (~/.claude/teams/*/inboxes/team-lead.json)
  • Messages not delivered to user UI
  • Permission requests not shown (but also stored in inbox)

After restart:

  • Agent messages delivered correctly via <teammate-message> tags
  • Permission dialogs appear (but still crash)

Note: Restart improved message routing but did NOT fix the core permission dialog crash bug.

---

Reproducible Test Case

Simplest reproduction:

# 1. Start Claude Code
claude

# 2. Create team
TeamCreate(team_name="debug-test", description="Bug test")

# 3. Spawn agent with destructive command
Agent(
  name="test-agent",
  team_name="debug-test",
  model="sonnet",
  subagent_type="general-purpose",
  prompt="Run: rm -rf /tmp/test-file-12345"
)

# 4. Observe crash when permission dialog appears

Important: Use a destructive command like rm -rf to reliably reproduce. Commands like sleep may be auto-approved by internal heuristics.

Command Behavior Patterns

Commands that trigger permission dialog → crash:

  • rm / rm -rf (destructive file operations)
  • mv on existing files
  • Other operations Claude Code classifies as dangerous

Commands that may auto-approve (no crash):

  • sleep - benign utility command
  • date - read-only system info
  • whoami - read-only user info
  • Other obviously safe operations

Commands typically on allowlist (no prompt needed):

  • git *
  • cd *
  • ls *
  • grep *
  • make *

Key Finding: Claude Code has built-in read-only command recognition. Commands like ls, cat, head, tail, grep, find, wc, diff, stat, du, cd, and read-only git operations run without prompts in every mode. This built-in list is not configurable. Commands like sleep may also be treated as benign and auto-approved, while destructive commands like rm -rf always require explicit permission unless pre-approved via allowlist. Only destructive commands reliably trigger the permission dialog, and therefore the crash.

Verified Test Results (2026-04-17)

Test 1: Team-Lead Permission Dialogs ✅

  • Commands: touch /tmp/test-file-12345 and rm -rf /tmp/test-file-12345
  • Permission dialogs appeared for both
  • User approved both successfully
  • Commands executed without crash
  • Conclusion: Permission dialogs work correctly for team-lead

Test 2: Spawned Agent Permission Dialog ❌

  • Command: rm -rf /tmp/test-file-12345
  • Permission dialog appeared
  • Immediate crash with H.toolUseContext.getAppState is not a function
  • User could not approve or deny
  • Conclusion: Permission dialogs crash when triggered by spawned agents

Observation: The same command (rm -rf) triggers functional permission dialogs for team-lead but crashes when requested by spawned agents. The bug appears to be in the permission dialog code path used when spawned agents request permission, not in command classification or allowlist logic.

UI Difference Between Team-Lead and Agent Dialogs

Team-Lead Permission Dialog (Working):

 Bash command
 
   touch /tmp/test-file
   Create test file
 
 Do you want to proceed?
 ❯ 1. Yes
   2. Yes, and always allow access to tmp/ from this project
   3. No

Spawned Agent Permission Dialog (Crashes):

 Bash command · @test-agent
 
   rm -rf /tmp/test-file
   Remove test file
 
 Do you want to proceed?
 ❯ 1. Yes
   2. No
 
  ERROR  H.toolUseContext.getAppState is not a function

Observed Difference: Agent dialogs include agent name in header ("· @test-agent"), while team-lead dialogs do not.

Hypothesis: The agent-attributed dialog may follow a different UI code path that attempts to call H.toolUseContext.getAppState(). The error occurs at line 8233:15642 in the bundled CLI. Team-lead dialogs work correctly, possibly because they don't trigger this code path.

Note: Without access to the harness source code, we cannot definitively determine whether the agent attribution is the actual cause or merely correlated with the crash.

---

Permission Configuration Hierarchy

Claude Code follows a tiered settings precedence (highest to lowest priority):

Settings Precedence

  1. Managed settings (cannot be overridden, even by CLI args)
  2. Command line arguments (session-only overrides)
  3. Local project settings (.claude/settings.local.json)
  4. Shared project settings (.claude/settings.json)
  5. User settings (~/.claude/settings.json)

Common Settings File Locations

Global User Settings:
~/.claude/settings.json - applies to all sessions

Projects Directory Settings:
<projects-dir>/.claude/settings.json - applies to all repos under that directory

Repository-Specific Settings:
<repo>/.claude/settings.json - applies only within that repo

Local Project Settings (gitignored):
<repo>/.claude/settings.local.json - per-developer overrides, not checked in

Merge Behavior

Deny rules take precedence: If a tool is denied at ANY level, no other level can allow it.

Allow rules are additive: Allow rules from multiple levels are combined. A command matching an allow pattern at ANY applicable level will be auto-approved (unless blocked by a deny rule).

Evaluation order: deny → ask → allow. The first matching rule wins within each level, then precedence rules determine which level takes priority.

Reference: See https://code.claude.com/docs/en/permissions for complete permission system documentation.

Example Allowlist Entries

Typical global settings might include broad patterns:

{
  "permissions": {
    "allow": [
      "Bash(git:*)",
      "Bash(cd:*)",
      "Bash(*&&*git*)",
      "Bash(*&&*)",
      "Read(*)",
      "Write(*)"
    ]
  }
}

While project-specific settings might be more conservative:

{
  "permissions": {
    "allow": [
      "Bash(git:*)",
      "Bash(ls:*)",
      "Read(*)",
      "Edit(*)"
    ]
  }
}

Commands like rm, sleep, date, whoami are typically NOT on allowlists, triggering either:

  1. Permission dialog (for destructive ops) → crash when spawned agents request permission
  2. Auto-approval (for benign ops via internal heuristics) → no crash

---

Expected Behavior

  1. Agent requests permission
  2. Permission dialog appears in user's UI
  3. User can select "Yes" or "No"
  4. Command executes or is denied based on user choice
  5. No crash

Actual Behavior

  1. Agent requests permission
  2. Permission dialog appears in user's UI
  3. Immediate crash with toolUseContext.getAppState is not a function
  4. Cannot approve or deny
  5. Agent stuck waiting indefinitely
  6. Session becomes unusable

---

Related Information

This may be related to GitHub issue #49865 (user-reported crashes with agent teams).

The toolUseContext object appears to be missing the getAppState method specifically in the context of spawned agents. The same permission flow works correctly for the parent/team-lead session, suggesting the context is initialized differently for spawned agents.

The error occurs in the permission explainer flow (around line 8233 in the bundled CLI), likely when trying to determine application state for the permission decision.

---

---

Notes on Agent Teams Feature

Agent teams is a research preview feature that requires CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1. The CHANGELOG shows a history of agent team bugs related to message passing, permission handling, and environment propagation across versions. This permission dialog crash appears to be a new issue not yet addressed in recent releases.

Claude Code is closed-source, so the exact cause of the toolUseContext.getAppState error cannot be determined without access to the harness code.

---

---

Report Attribution

Primary Testing and Observation: Colin Leong

  • Ran all Claude Code sessions and agent team tests
  • Observed and documented the permission dialog crashes
  • Provided initial bug observations and reproduction context
  • Directed testing scenarios and validation steps
  • Captured error messages and stack traces from tmux sessions

Documentation and Analysis: Claude Sonnet 4.5

  • Structured and wrote the bug report documentation
  • Researched Claude Code permissions system documentation
  • Investigated the Claude Code GitHub repository
  • Analyzed error patterns and formulated hypotheses
  • Organized findings into reproducible test cases

Collaboration: This report is a joint effort combining hands-on testing (Leong) with systematic documentation and analysis (Sonnet 4.5). User feedback shaped the testing approach and ensured accuracy of observations vs. hypotheses.

---

Report Date: 2026-04-17
Claude Code Version: 2.1.112
Issue Severity: Critical (blocks all agent team workflows requiring Bash approval)
Environment: Linux, AWS Bedrock backend

cleong110 · 3 months ago

Hmmm, just tried it in 2.1.111 and still had the bug. Fresh tmux session and everything. Checked claude --version, updated the symlink to point to the .111, checked /stats inside claude.... same bug

cleong110 · 3 months ago

Ah maybe not, autoupdated keeps changing me to 2.112.
Edit: disabled autoupdate, checked claude --version, had team lead also run claude --version, no more 2.1.112, but same bug

OK, version 2.1.110 works.

Version Testing Update

I tested across three versions to identify when this regression was introduced:

| Version | Status | Notes |
|---------|--------|-------|
| 2.1.110 | ✅ Works | Permission dialog functions correctly, no crash |
| 2.1.111 | ❌ Broken | Permission dialog crashes immediately |
| 2.1.112 | ❌ Broken | Same crash as 2.1.111 |

Conclusion: This is a regression introduced in v2.1.111. The functionality worked correctly in 2.1.110.

Testing note: I had to disable autoupdate in ~/.claude/settings.json to test older versions:

{
  "autoUpdate": false
}

This narrows the scope for investigation - the bug was introduced in changes between 2.1.110 and 2.1.111, specifically in the spawned agent permission dialog code path.

How to Downgrade to Claude Code v2.1.110

Quick Guide

1. Disable Auto-Update

Edit ~/.claude/settings.json and add:

{
  "autoUpdate": false
}

2. Symlink to v2.1.110

# Remove current symlink
rm ~/.claude/claude

# Create symlink to 2.1.110
ln -s ~/.claude/versions/2.1.110/claude ~/.claude/claude

3. Verify Version

claude --version
# Should output: 2.1.110 (Claude Code)

Reverting to Latest

To go back to the latest version:

# Remove symlink
rm ~/.claude/claude

# Link to latest
ln -s ~/.claude/versions/$(ls -1 ~/.claude/versions | sort -V | tail -1)/claude ~/.claude/claude

# Re-enable auto-update in settings.json
# (remove or set "autoUpdate": true)

Notes

  • The ~/.claude/versions/ directory contains all downloaded Claude Code versions
  • Auto-update must be disabled or it will overwrite your symlink
  • Your settings, teams, and task lists are separate from the binary version and won't be affected
ihsaner-legion · 3 months ago

Ran into the same issue with tmux managed experimental agent teams. Same outcome - parent team crashes with "not a function" error.

jordanrendric · 3 months ago
Ah maybe not, autoupdated keeps changing me to 2.112. Edit: disabled autoupdate, checked claude --version, had team lead also run claude --version, no more 2.1.112, but same bug OK, version 2.1.110 works. ## Version Testing Update I tested across three versions to identify when this regression was introduced: Version Status Notes 2.1.110Works Permission dialog functions correctly, no crash 2.1.111Broken Permission dialog crashes immediately 2.1.112Broken Same crash as 2.1.111 Conclusion: This is a regression introduced in v2.1.111. The functionality worked correctly in 2.1.110. Testing note: I had to disable autoupdate in ~/.claude/settings.json to test older versions: { "autoUpdate": false } This narrows the scope for investigation - the bug was introduced in changes between 2.1.110 and 2.1.111, specifically in the spawned agent permission dialog code path. # How to Downgrade to Claude Code v2.1.110 ## Quick Guide ### 1. Disable Auto-Update Edit ~/.claude/settings.json and add: { "autoUpdate": false } ### 2. Symlink to v2.1.110 # Remove current symlink rm ~/.claude/claude # Create symlink to 2.1.110 ln -s ~/.claude/versions/2.1.110/claude ~/.claude/claude ### 3. Verify Version claude --version # Should output: 2.1.110 (Claude Code) ## Reverting to Latest To go back to the latest version: # Remove symlink rm ~/.claude/claude # Link to latest ln -s ~/.claude/versions/$(ls -1 ~/.claude/versions | sort -V | tail -1)/claude ~/.claude/claude # Re-enable auto-update in settings.json # (remove or set "autoUpdate": true) ## Notes The ~/.claude/versions/ directory contains all downloaded Claude Code versions Auto-update must be disabled or it will overwrite your symlink * Your settings, teams, and task lists are separate from the binary version and won't be affected

@cleong110 Just adding that on macOS my symlink was in ~/.local/bin/claude, I didn't have version 2.1.110 downloaded locally, so I ran which claude to see where it was pointing:

which claude
claude: aliased to ~/.local/bin/claude

I ran rm ~/.local/bin/claude, then I ran the official installation script, but with the -s 2.1.110 argument, like this:

curl -fsSL https://claude.ai/install.sh | bash -s 2.1.110

For some reason, when I ran the script this way I was getting the error:

curl -fsSL https://claude.ai/install.sh | bash -s 2.1.110
Setting up Claude Code...

✘ Installation failed

EACCES: permission denied, open '/Users/jordanvasconcelos/.local/share/claude/versions/2.1.110'

Try running with --force to override checks

So I decided to add a sudo to the command, like this:

curl -fsSL https://claude.ai/install.sh | sudo bash -s 2.1.110

And it was done

jordanrendric · 3 months ago

Ah, and to get Opus 4.7 working on this version, I used the command /model opus-4-7[1m]

mrmemes-eth · 3 months ago

Confirming the same issue on 2.1.112, macOS, in the team-lead-managing-teammates workflow (spawning teammates via Agent with team_name set; team lead routes their work and approves tool use). Same underlying bug as @jonleung's direct-teammate-conversation workflow; different user-facing flow, same crash signature.

Three crashes in one real working session today. Trigger each time was identical: a spawned teammate needed permission to use a tool the team-lead should approve. The team-lead session died before any approval prompt rendered, matching the reported stack trace.

One downstream datapoint that may be useful for triage: on each crash, attached MCP servers disconnected entirely and their deferred tools dropped out of the remaining session. So the failure mode extends beyond "missing permission prompt", it cascades into losing any MCP tools the session was using, which blocks recovery paths that depend on those tools.

Downgrading to 2.1.110 per @cleong110's instructions (already cached locally at ~/.local/share/claude/versions/2.1.110, so no reinstall needed). Thanks for the detailed version bisection and downgrade recipe.

dmer41 · 2 months ago

Still hitting this on v2.1.113 (Apr 17 2026).

Repro:

  • macOS 14, iTerm2, teammateMode=tmux, CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
  • Spawn sonnet teammate via Task tool with mode: "bypassPermissions"
  • Teammate issues plain Bash like echo "hi" or python3 -c "..."
  • Teammate pane shows "Waiting for team lead approval"
  • Team lead session: permission_request lands in ~/.claude/teams/<team>/inboxes/team-lead.json but no approval UI renders
  • Teammate deadlocks indefinitely; even SendMessage {type:"shutdown_request"} can't recover, only tmux kill-pane works

Attempted workarounds — none work:

  • mode: "bypassPermissions" on Agent spawn
  • ~/.claude/settings.json "defaultMode": "auto"
  • ~/.claude/settings.json "defaultMode": "bypassPermissions"
  • Project-committed .claude/settings.json with broad Bash(python3:*) / Edit(...) / Write(...) allow rules
  • Project .claude/settings.local.json with the same rules

Is the fix landing in the next release? Current state is a hard block for any multi-agent workflow using sonnet teammates. Related: #26479, #43406, #24108.

github-actions[bot] · 2 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.