TUI shows background sub-agent tool call as 0s / 0 tokens while the agent is still running

Aberta
#845 1 comentário 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
72/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
bash, javascript
Domínio
cli, observability

Direção de pesquisa

Comece reproduzindo o fluxo de background-agent na TUI com sleep 12; echo done e, em seguida, inspecione o renderizador de chamadas de ferramentas e o tratamento de ferramentas do agente em dist/cli.mjs. Rastreie como duration_ms, total_tokens, tool_uses e turns são vinculados antes e depois de agent_output. Está concluído quando uma chamada em andamento tem um estado ativo claro em vez de 0s/0 tokens com aparência final, e as chamadas concluídas exibem os valores retornados.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Summary

When the main agent dispatches a background sub-agent (agent/Task tool with run_in_background), the TUI renders the tool-call block with 0s duration and 0 tokens from the moment it is launched and for the entire time it is running. Real usage (tokens, duration, turns) only appears after the agent finishes and agent_output returns.

Impact: while a long-running sub-agent is in flight, there is no in-progress signal (no spinner, no elapsed time, no token counter), and the "0s / 0 tokens" reading looks like a completed no-op. I cannot tell whether the sub-agent is alive, stuck, or done while waiting.

Expected Behavior

While a sub-agent is running, its tool-call block should indicate an active/in-progress state (e.g. spinner or live elapsed time), and should not display a final-looking "0s / 0 tokens". Duration/token/turn stats should populate when the sub-agent completes (or stream live if available). Once finished, the block should show the real values returned by agent_output.

Actual Behavior

Immediately after launching a background sub-agent, the tool-call block shows 0s and 0 tokens. These values stay at 0s/0 tokens for the whole run even though the agent is actively working. Only after the agent completes and I call agent_output do real numbers appear (observed ~22k-30k tokens, 4.6-7.3s, 1 tool_use, 2 turns). No in-progress indicator is shown, so the block appears finished/no-op while the agent is actually still running.

Steps to reproduce the issue
  1. Start Command Code (cmd) in a TUI session — reproduced both with yolo mode on and off, so it is not yolo-specific. (Linux (WSL2) — Ubuntu 24.04.3 LTS, kernel 6.18.33.2-microsoft-standard-WSL2, x86_64 and WSL2, TERM=xterm-256color (Windows Terminal); TERM_PROGRAM is empty)
  2. Ask the agent to launch a background sub-agent, e.g.: "dispatch a background sub-agent that runs sleep 12; echo done and returns the output" (agent tool with run_in_background: true).
  3. Immediately observe the tool-call block in the TUI: it shows 0s / 0 tokens.
  4. Keep watching for the whole run (a ~21s agent makes this easy) — it stays at 0s / 0 tokens, with no spinner/elapsed time/live tokens.
  5. Wait for it with agent_output — only then does the block show real usage (tokens, duration, turns).
Command Code Version

1.53.1

Operating System

Linux

Terminal/IDE

Unknown

Shell

bash

Session file (optional)

command-code-session-84b81546.html

Fix prompt (optional)

In the Command Code TUI, the tool-call block for the background sub-agent (Task/agent tool launched with run_in_background) renders duration and token counts as 0s / 0 tokens the moment it is dispatched and keeps showing 0/0 for the entire run, with no in-progress indicator. It only shows real usage after the agent completes and agent_output returns.

Expected: while the sub-agent is running, show an active state (spinner and/or live elapsed time) and do not show a final-looking 0s / 0 tokens; populate duration/tokens/turns from the agent's actual result when it completes (or stream them live if available).

Likely location: the TUI renderer for tool calls / the agent (Task) tool in the Command Code bundle (dist/cli.mjs), where tool-call metadata (duration_ms, total_tokens, tool_uses, turns) is bound to the rendered row. Currently these fields default to 0/undefined until the final result is attached, and the "running" branch is not distinguished from the "finished" branch.

Additional context

Reproduced on 1.53.1 (latest) with yolo mode on. Also reproduced on 1.53.0.
Latest run: background sub-agent ran ~21.5s (sleep 12; echo ...) and completed with 63803 tokens, 3 tool_uses, 4 turns, 21588ms — yet the TUI tool-call block showed 0s / 0 tokens for the entire in-flight period.

Earlier session (1.53.0, three background agents, all completed):
- bg-1: 22828 tokens, 1 tool_use, 2 turns, 7294ms
- bg-2: 29954 tokens, 1 tool_use, 2 turns, 4618ms
- bg-3: 30000 tokens, 1 tool_use, 2 turns, 7003ms
agent_output itself (wait / status / list / parallel waits) returns correct data — the bug is isolated to the TUI rendering of the in-flight tool call, not the agent runtime.

Linguagem predominante
Sem dados de linguagem
Estrelas
4k
Forks
350
Métricas de merge de PRs
Nenhum PR com merge em 30d

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de CommandCodeAI/command-code

Todas as issues de CommandCodeAI/command-code

Issues semelhantes

Mais issues de CLI

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.