Skip to content

Allow agent authoring tools to be reloaded after writes - #3733

Merged
kojiwakayama merged 4 commits into
mainfrom
fix/reload-agent-write-tools
Aug 14, 2026
Merged

Allow agent authoring tools to be reloaded after writes#3733
kojiwakayama merged 4 commits into
mainfrom
fix/reload-agent-write-tools

Conversation

@kojiwakayama

@kojiwakayama kojiwakayama commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • keep create_agent and update_agent unavailable immediately after a successful agent write
  • keep those authorized tools in the deferred search catalog instead of removing them from the run
  • let an explicit tool_search reload an agent authoring tool for the next step
  • preserve the existing eager-mode final-response guard

Root cause

The post-write guard passed both tool names as excluded tools and then removed them from the visible, deferred, and authorized exposure sets. In deferred mode, tool_search searches only the deferred set, so the model could not recover either authoring tool after the first successful write.

Red-green evidence

  • generate and stream regressions first failed after the first successful write because the second tool_search could not expose the requested authoring tool
  • the generate regression also covers a catalog with no other deferred tool, which requires the runtime to restore tool_search itself
  • the stream regression reloads update_agent after create_agent, covering both guarded authoring tools

Verification

  • focused tool exposure, durability, and runtime refresh suites: 51 tests and 27 BDD steps passed
  • deno task lint:ci
  • generated API reference check
  • git diff --check

Closes veryfront/veryfront-issue-inbox#463

Summary by CodeRabbit

  • New Features

    • Agent workflows can now defer loading certain tools until they are needed, while keeping tool search available.
    • Repeated discovery and execution of agent creation and update tools now work reliably in both standard and streaming responses.
  • Bug Fixes

    • Improved tool visibility and execution handling when deferred tools are reloaded.
  • Documentation

    • Updated the Agent Runtime source reference link in the API documentation.

@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review

@github-actions

Copy link
Copy Markdown

📦 Client bundle boundary

Entrypoint Modules Source size Server leaks
src/index.client.ts 454 3065 KiB ⚠️ 39 known

A server module in a client graph aborts hydration in the browser. New leaks fail CI; known leaks are tracked in scripts/lint/client-bundle-baseline.json to burn down.

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@kojiwakayama, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 24 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bde8c703-8f45-490a-a644-0de4a4ebcffd

📥 Commits

Reviewing files that changed from the base of the PR and between 5d687ae and f46a0af.

📒 Files selected for processing (4)
  • docs/api-reference/veryfront/agent.md
  • src/agent/runtime/index.ts
  • src/agent/runtime/request-scoped-tool-replacement.test.ts
  • src/agent/runtime/tool-exposure-runtime.test.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 913dd946-2480-4903-a8f9-16bbaf8d8605

📥 Commits

Reviewing files that changed from the base of the PR and between 8716d2c and 5d687ae.

📒 Files selected for processing (3)
  • docs/api-reference/veryfront/agent.md
  • src/agent/runtime/index.ts
  • src/agent/runtime/tool-exposure-runtime.test.ts

📝 Walkthrough

Walkthrough

The agent runtime now supports deferred loading for guarded tools. Generate and stream loops can rediscover and execute guarded project-agent-write tools through tool search. Tests cover repeated discovery and execution. The API reference link points to the updated source line.

Changes

Deferred tool exposure

Layer / File(s) Summary
Reloadable final-response guard
src/agent/runtime/index.ts, docs/api-reference/veryfront/agent.md
The guard can defer guarded tools, restore tool search, detect reloaded tools, sort tool collections, and update the AgentRuntime source link.
Generate and stream integration
src/agent/runtime/index.ts
Generate and stream modes apply eager exclusion and deferred exposure rules. The guard is disabled when tool search reloads a guarded project-agent-write tool.
Deferred generate and stream coverage
src/agent/runtime/tool-exposure-runtime.test.ts
Tests cover repeated create_agent and update_agent discovery, execution, exposure, streamed events, execution counts, and final responses.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 5d687

The change restores agent authoring tools through explicit search after a successful write while preserving the existing safety guard; no actionable merge-blocking risk remains after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant GenerateOrStream
  participant FinalResponseGuard
  participant ToolSearch
  participant AgentTool
  GenerateOrStream->>FinalResponseGuard: apply deferred exposure
  FinalResponseGuard->>ToolSearch: expose tool search
  GenerateOrStream->>ToolSearch: search for guarded tool
  ToolSearch->>AgentTool: reload project-agent-write tool
  ToolSearch-->>GenerateOrStream: return reloaded tool
  GenerateOrStream->>FinalResponseGuard: disable guard after reload
Loading

Possibly related PRs

Suggested reviewers: kwakayama

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: reloading agent authoring tools after write operations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/reload-agent-write-tools

Comment @coderabbitai help to get the list of available commands.

@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: 5d687ae58e

ℹ️ 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 src/agent/runtime/index.ts
Comment thread src/agent/runtime/index.ts Outdated
@kojiwakayama
kojiwakayama marked this pull request as draft August 14, 2026 23:01
@kojiwakayama
kojiwakayama marked this pull request as ready for review August 14, 2026 23:06
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review

@kojiwakayama
kojiwakayama marked this pull request as draft August 14, 2026 23:08
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: f6cc3615fa

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

@kojiwakayama
kojiwakayama marked this pull request as ready for review August 14, 2026 23:16
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

The failed coverage shard exposed a related hosted-boundary regression: pre-write deferred tool names entered the first provider prompt. I reproduced it locally, scoped deferred inventory synchronization to the post-write guard, and verified the exact failing hosted test plus the original review regressions. The four focused files pass 45 tests and 74 BDD steps, type checking passes, generated docs are current, and the repository lint gate is green. @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: 8e66008e7a

ℹ️ 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 src/agent/runtime/index.ts Outdated
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: f46a0af982

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

@kojiwakayama
kojiwakayama added this pull request to the merge queue Aug 14, 2026
Merged via the queue into main with commit 71f02e5 Aug 14, 2026
34 checks passed
@kojiwakayama
kojiwakayama deleted the fix/reload-agent-write-tools branch August 14, 2026 23:44
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