Skip to content

feat(coding-agent): highlight heredocs and inline scripts in shell calls - #2

Open
ivanmilevtues wants to merge 3 commits into
mainfrom
test/tool-call-stats
Open

ivanmilevtues wants to merge 3 commits into
mainfrom
test/tool-call-stats

Conversation

@ivanmilevtues

@ivanmilevtues ivanmilevtues commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Shell calls can contain Python, JavaScript, Rust, and other languages inside heredocs or inline scripts. This change identifies those sections and highlights them in their own language, with long bodies collapsed until expanded.

The new shell parser feeds the Bash renderer. Bash and Write share an incremental highlighting cache, and changing the theme invalidates the cached styling. PowerShell keeps its existing display behavior.

Adapted from earendil-works/pi#10021 by Armin Ronacher to the current renderer and tool-timing APIs. This is a CodeBoarding demonstration PR and is not intended to merge.

Useful paths to explore in the architecture diff:

  • Bash renderer → new embedded-script parser.
  • Bash and Write renderers → shared streaming highlight cache.
  • Renderers → theme identity and language highlighting.

Validation: npm run check passes; all 54 tests across shell parsing, streaming highlighting, and tool rendering pass. The branch includes the current main baseline and licensed CodeBoarding workflow.

The licensed CodeBoarding review passed: 8 analyzed source files changed, affecting 4 components and 3 detailed connections. The top-level diagram highlights one connection. Expand Coding Agent Application to explore the new parser under System Utilities and the tool-rendering/theme relationships; the parser does not create a separate graph component at this analysis depth.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-10T19:31:30.364639Z d537fb8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

CodeBoarding review

Status: 4 changed components

See the full change in CodeBoarding.

graph LR
    n_Coding_Agent_Application["Coding Agent Application"]
    n_AI_Provider_Runtime["AI Provider Runtime"]
    n_Durable_State_Codemode_Runtime["Durable State #38; Codemode Runtime"]
    n_Workspace_Automation_Scripts["Workspace Automation Scripts"]
    n_Terminal_UI_Toolkit["Terminal UI Toolkit"]
    n_Agent_Evaluation_Harness["Agent Evaluation Harness"]
    n_MCP_Protocol_Client["MCP Protocol Client"]
    n_Agent_Core_Loop["Agent Core Loop"]
    n_Telemetry_Instrumentation["Telemetry Instrumentation"]
    n_Coding_Agent_Application -- "queries models and provider credentials" --> n_AI_Provider_Runtime
    n_Coding_Agent_Application -- "renders terminal UI views and layouts using" --> n_Terminal_UI_Toolkit
    n_Coding_Agent_Application -- "instantiates and drives agent execution loop" --> n_Agent_Core_Loop
    n_Coding_Agent_Application -- "executes scripts in codemode sandboxes" --> n_Durable_State_Codemode_Runtime
    n_Coding_Agent_Application -- "manages MCP authentication and transports" --> n_MCP_Protocol_Client
    n_AI_Provider_Runtime -- "prompts interactive login flow" --> n_Coding_Agent_Application
    n_Durable_State_Codemode_Runtime -- "delegates execution callbacks to agent runtime" --> n_Coding_Agent_Application
    n_Durable_State_Codemode_Runtime -- "queries available model catalog" --> n_AI_Provider_Runtime
    n_Workspace_Automation_Scripts -- "hydrates model catalog definitions" --> n_AI_Provider_Runtime
    n_Workspace_Automation_Scripts -- "loads session and auth configurations" --> n_Coding_Agent_Application
    n_Workspace_Automation_Scripts -- "persists state in durable documents" --> n_Durable_State_Codemode_Runtime
    n_Terminal_UI_Toolkit -- "dispatches layout and input events to views" --> n_Coding_Agent_Application
    n_Agent_Evaluation_Harness -- "benchmarks model runtimes" --> n_Coding_Agent_Application
    n_Agent_Evaluation_Harness -- "tests provider model interfaces" --> n_AI_Provider_Runtime
    n_Agent_Evaluation_Harness -- "verifies agent state in UI evaluations" --> n_Agent_Core_Loop
    n_MCP_Protocol_Client -- "persists tokens via agent credential store" --> n_Coding_Agent_Application
    n_Agent_Core_Loop -- "dispatches events to message stream" --> n_AI_Provider_Runtime
    classDef added fill:#1f883d,stroke:#0b5d23,color:#ffffff;
    classDef modified fill:#bf8700,stroke:#7d4e00,color:#ffffff;
    classDef deleted fill:#cf222e,stroke:#82071e,color:#ffffff,stroke-dasharray:5 3;
    class n_Coding_Agent_Application modified;
    linkStyle 1 stroke:#7d4e00,stroke-width:2px;
Loading

download artifacts · run 38928902209

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d537fb8ae3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/agent/src/agent-loop.ts Outdated
? await failToolCallsFromTruncatedMessage(toolCalls, emit)
: await executeToolCalls(currentContext, message, config, signal, emit);
toolResults.push(...executedToolBatch.messages);
for (const result of executedToolBatch.messages) recordToolCall(result.toolName, result.isError);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Count calls made through runToolCall

When a tool invokes another tool through the exported runToolCall() pipeline, the nested call never reaches this block, so only the outer tool is counted. This occurs in packages/coding-agent/src/core/agent-session.ts, where nested tool calls delegate directly to runToolCall(); for example, a codemode call that invokes read twice records one codemode call and zero read calls or failures. Record outcomes in the common runToolCall/finalization path, while avoiding double-counting model-issued calls.

Useful? React with 👍 / 👎.

Comment thread packages/agent/src/tool-call-stats.ts Outdated
errors: number;
}

const stats = new Map<string, ToolCallStat>();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Isolate counters per agent session

When multiple Agent instances run in the same Node process, this singleton map merges their calls even though agent state and sessionId are instance-specific. A session reading getToolCallStats() therefore reports tools and failures from unrelated sessions, and calling resetToolCallStats() for one session erases the other sessions' totals, including concurrent runs. Store the counters on the agent/run or key the read, record, and reset APIs by session.

Useful? React with 👍 / 👎.

@ivanmilevtues

Copy link
Copy Markdown
Member Author

/codeboarding

Refresh the architecture diff for the Amp community showcase using the migrated workflow.

This comment is AI-generated by Amp.

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

CodeBoarding review · failed

The LLM provider's token or credit quota is exhausted. Add credits or raise the quota, then re-run.

See the workflow logs.

ivanmilevtues and others added 2 commits October 16, 2026 18:01
Adapt upstream earendil-works#10021 to the current renderers for the CodeBoarding architecture demo.

Co-authored-by: Armin Ronacher <armin.ronacher@active-4.com>
@ivanmilevtues ivanmilevtues changed the title feat(agent): count tool calls and failures per tool feat(coding-agent): highlight heredocs and inline scripts in shell calls Oct 16, 2026

This branch has not been deployed

No deployments
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