Skip to content

feat(coderd/x/chatd): add include_tool_calls to wait_agent - #53

Merged
ibetitsmike merged 10 commits into
mainfrom
mike/todo-transcripts-8-wait-agent-tool-calls
Nov 9, 2026
Merged

ibetitsmike merged 10 commits into
mainfrom
mike/todo-transcripts-8-wait-agent-tool-calls

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Xum opened this PR on behalf of @ibetitsmike.

Part of #10. Stacked on #52 (search_chats).

Adds an include_tool_calls option to wait_agent (PRD R5.5): with it set to N, the result also carries the child's last N tool calls, so a parent can see what a child that timed out is doing, or how it reached its report. Behind fork-chat-todos. With the flag off, wait_agent is the upstream tool, schema included.

  • No edit to subagent.go: appendForkTools wraps the wait_agent tool (root and nested) in forkWaitAgentTool, which adds the parameter to the schema, validates it (0 to 20), runs the upstream tool unchanged (it ignores the extra field) and adds tool_calls to its JSON result. Error results are returned as they are, so a chat that is not a child gets no tool calls.
  • Each entry has tool_name, args, result (once there is one), is_error and created_at (the part's emit time, else the message time), oldest first. A result settles only the newest call with its ID, since providers can reuse call IDs. chat_id is parsed with the upstream parseSubagentToolChatID. Args and results are cut with chatloop.TruncateToolResultText at 2 KiB; a cut value becomes a JSON string because a cut JSON value is not valid.
  • The child's messages are read as the chat owner (httpmw.UserRBACSubject and dbauthz.As), never as chatd. Only both visibility rows are used (the query already drops model-only rows; user-only projections are skipped), and they go through db2sdk.ChatMessage, which applies StripInternal. One call scans at most 200 rows.
  • ARCHITECTURE.md: the fork TODO line now names the option.

Validation: TestWaitAgentIncludeToolCalls passes against Postgres 17 with the store wrapped in dbauthz: the schema keeps chat_id and adds include_tool_calls; a chat ID with a leading space works; the last 2 calls come back oldest first with paired results and is_error, a pending call has no result, an older call that reuses a later call's ID gets no result, an emit time is kept, long args are truncated, a user-only call and provider metadata are absent; without the option there are no tool calls; out-of-range and non-integer values and a chat that is not a child are errors. Negative controls that drop the visibility check, is_error, the result removal, the emit time or the chat_id trim each fail the test. ./coderd/x/chatd/... passes; go vet is clean.

UAT on a dev instance with a local model (fc17b34; the later commits only answer review), from chats owned by a plain member: a root spawned a general child that made 20 parallel todo tool calls, then called wait_agent with include_tool_calls: 3. The result carried the report and the child's calls 18, 19 and 20 in order, each with the result of its own call ID (checked in the database).

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T14:52:16.126369Z 22516fd Manual request
ℹ️ 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.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@codex review

@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: fc17b34630

ℹ️ 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 coderd/x/chatd/ARCHITECTURE.md Resolved
Comment thread coderd/x/chatd/fork_wait_agent.go Resolved
Comment thread coderd/x/chatd/fork_wait_agent.go Resolved
Comment thread coderd/x/chatd/fork_wait_agent.go Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 997fa222e0

ℹ️ 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".

…-7-search-chats

# Conflicts:
#	coderd/x/chatd/fork_chat_todos_internal_test.go
#	coderd/x/chatd/fork_tools.go
…hats' into mike/todo-transcripts-8-wait-agent-tool-calls
… tool calls

truncateToolCallJSON duplicated truncateTranscriptJSON from the
read_chat_transcript tool apart from its fixed size limit.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 22516fda0e

ℹ️ 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".

Base automatically changed from mike/todo-transcripts-7-search-chats to main November 9, 2026 14:52
…-8-wait-agent-tool-calls

# Conflicts:
#	coderd/x/chatd/ARCHITECTURE.md
#	coderd/x/chatd/fork_tools.go
@ibetitsmike
ibetitsmike merged commit 736de76 into main Nov 9, 2026
9 checks passed
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) merged this on behalf of @ibetitsmike.

Merged at 7d5df06 after these checks:

  • 7d5df06 merges main ab33ec5 into 22516fd. With index and @@ lines removed, git diff origin/main...7d5df06aa1 matches the 22516fd patch byte for byte.
  • Codex found no major issues at 14:52:14Z on 22516fd, and 0 review threads are unresolved.
  • fork-ci run 42639296778 passes all checks on the exact head.
  • Lead diff review: include_tool_calls is registered only under the fork-chat-todos experiment (appendForkTools). It reads tool calls only after the upstream wait_agent accepts the chat_id, which proves the child is one this chat may wait on. It reads as the chat owner's RBAC subject (dbauthz.As) and truncates long args and results.
  • git merge-tree against main is clean. The local deployment of ab33ec5 (feat(coderd/x/chatd): add the search_chats chat tool #52, fix: regenerate API docs for the chat todo routes #55) is healthy, so the merge slot is open.

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