Skip to content

fix(agent): escape task notification summaries and surface subagent consumption - #51

Merged
savass33 merged 1 commit into
mainfrom
fix/agent-notification-and-progress-ui
Sep 10, 2026
Merged

fix(agent): escape task notification summaries and surface subagent consumption#51
savass33 merged 1 commit into
mainfrom
fix/agent-notification-and-progress-ui

Conversation

@savass33

@savass33 savass33 commented Sep 9, 2026

Copy link
Copy Markdown

Substitui o #49. Parte a partir do main atual (pós-v0.15.21) e traz só o que continua válido de lá.

O que mudou

Envelope da notificação de taskdescription é input de tool vindo do modelo e é interpolado direto no elemento <summary>. Um < fecha a tag cedo: o parser lê um summary truncado seguido do que a description afirmar depois, inclusive um <status> forjado. Passa a remover os brackets, com teste que falha se a sanitização sair.

Consumo do subagente na lista de background tasks — as linhas local_agent mostravam só descrição e status, com token/tool count já disponíveis no task. Passa a exibir · N tokens · N tools, usando o result quando o agente terminou e o progress enquanto roda.

Model override em coordinator mode — era descartado em silêncio. Agora loga, então uma execução em modelo inesperado fica rastreável.

Sobre os slots do React Compiler

BackgroundTask.tsx é artefato compilado versionado (_c(92), import de react-compiler-runtime), e o build não regera — scripts/build.ts só faz shim de react/compiler-runtime e não há babel-plugin-react-compiler no projeto.

Por isso os 6 slots novos foram anexados em 92..97, com o cache subindo para _c(98), em vez de inseridos no meio da faixa do case "local_agent". Inserir no meio deslocaria os slots que os outros case do switch ainda leem: o case "in_process_teammate" usa 32..39. Como o array $ persiste entre renders da mesma instância, duas faixas sobrepostas fazem as guardas nunca baterem e a memoização morrer. Anexando no fim, nada mais se move.

O que ficou de fora do #49, e por quê

Todo o syncProgressUsageFromMessages e o tokenProgress.test.ts.

O main já corrigiu esse bug em 7d5b362 (v0.15.21), por outra arquitetura: o ProgressTracker guarda messages: Map<uuid, Message> e getTrackerUsage() calcula na leitura via agentUsageFromMessages(). É a mesma sacada — as referências acumuladas são o que o message_delta muta in-place — implementada como leitura preguiçosa em vez de recomputo eager, e com dedupe por uuid que a versão do #49 não tinha.

Mergear o #49 era pior que não mergear: o git faz auto-merge do LocalAgentTask.tsx sem conflito e o resultado escreve em tracker.latestInputTokens / cumulativeOutputTokens, campos que não existem mais.

LocalAgentTask.tsx(102,11): error TS2339: Property 'latestInputTokens' does not exist on type 'ProgressTracker'.
LocalAgentTask.tsx(103,11): error TS2339: Property 'cumulativeOutputTokens' does not exist on type 'ProgressTracker'.

E o "conserto óbvio" (readicionar os campos pra calar o TS) seria o pior caso: os writes viram no-op silencioso, porque getProgressUpdategetTokenCountFromTracker, que no main resolve por usageUpdates/messages.

Validação

  • tsc --noEmit: zero erros novos vs. o baseline do main (o baseline já tem 2350 linhas de erro pré-existentes, comparei os conjuntos).
  • bun test completo: 62 falhas idênticas às do main, 0 novas, 0 corrigidas — conjuntos comparados linha a linha.
  • bun test src/tasks/ src/tools/AgentTool/ src/components/tasks/: 16 pass, 0 fail.
  • Sanitização: verificado que o teste novo falha quando a escapagem é revertida.
  • Slots 92..97 conferidos: cada um aparece em exatamente dois pontos, todos na região nova, _c(98) com max slot 97 e nenhuma lacuna.

…onsumption

Three unrelated-but-small fixes around subagent reporting.

The agent description is model-supplied tool input interpolated straight into
the <summary> element of the task notification. A bracket in it closes the tag
early, so the parser reads a truncated summary followed by whatever the
description claimed next, a forged <status> included. Strip brackets, and add
a test that fails when the escaping is removed.

The background task list showed only a description and a status for
local_agent rows, while the token and tool counts were already on the task.
Show them, taking the finished result when the agent is done and live progress
otherwise. The React Compiler cache in that file is a checked-in artifact and
the build does not regenerate it, so the six new slots are appended at 92..97
and the cache grows to 98 rather than being inserted mid-range, which would
have shifted the slots the sibling switch branches still read.

A model override passed to a coordinator worker was dropped silently. Log it,
so a run on an unexpected model is traceable.
@savass33
savass33 force-pushed the fix/agent-notification-and-progress-ui branch from 4847554 to 0d01353 Compare September 10, 2026 18:53
@savass33
savass33 merged commit 8c9e44b into main Sep 10, 2026
15 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant