Skip to content

Introduce ToolBuildContext for tool construction#122

Merged
Sewer56 merged 1 commit into
mainfrom
feat/tool-build-context
May 29, 2026
Merged

Introduce ToolBuildContext for tool construction#122
Sewer56 merged 1 commit into
mainfrom
feat/tool-build-context

Conversation

@Sewer56
Copy link
Copy Markdown
Member

@Sewer56 Sewer56 commented May 29, 2026

Summary

Bundle workspace root and permissions into a single object passed when building tools, instead of sending them separately to every tool.

Motivation

Every tool builder needed the workspace root and permission config passed in individually. The workspace root also got canonicalized repeatedly. This groups those shared values into one object that's created once and reused.

Changes

  • New ToolBuildContext struct holds the canonicalized workspace root and optional permissions
  • build_resolver_for_tool now takes this context instead of separate arguments
  • Updated resolver logic and tests to use the new pattern
  • Agent runtime builds one context before constructing tools, simplifying each call

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

Review Change Stack

Warning

Review limit reached

@Sewer56, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 55 minutes and 45 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

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.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ebec6628-89b0-4884-96c1-93090ba45d5e

📥 Commits

Reviewing files that changed from the base of the PR and between 97cd01d and 6a58235.

📒 Files selected for processing (4)
  • src/reloaded-code-agents/src/path/resolver.rs
  • src/reloaded-code-core/src/lib.rs
  • src/reloaded-code-core/src/tool_context/mod.rs
  • src/reloaded-code-serdesai/src/agent_runtime/build.rs

Walkthrough

This PR introduces ToolBuildContext, a new struct that encapsulates a pre-canonicalized workspace root and optional permission ruleset for tool construction. The context is defined in a new tool_context module within the core crate and re-exported publicly. The build_resolver_for_tool function is refactored to accept &ToolBuildContext as its first parameter instead of receiving workspace root directly, eliminating redundant canonicalization calls. All unit tests and the agent build pipeline are updated to create a single context instance and pass it to resolver constructors, enabling centralized workspace root canonicalization before the tool resolver loop.

Possibly related PRs

  • Reloaded-Project/ReloadedCode#98: Both PRs refactor path resolver construction to rely on a canonicalized workspace root, with the main PR introducing ToolBuildContext as the centralized source of that root for build_resolver_for_tool calls.

  • Reloaded-Project/ReloadedCode#101: Both PRs revolve around build_resolver_for_tool and resolver selection; the main PR updates the function signature to use a shared ToolBuildContext, while the retrieved PR introduces the underlying resolver machinery that the refactor adapts.

  • Reloaded-Project/ReloadedCode#72: Both PRs modify the agent build pipeline in attach_standard_tools by wiring resolver construction differently; the main PR introduces ToolBuildContext to centralize workspace root canonicalization, while the retrieved PR selects tool variants based on per-agent settings.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Introduce ToolBuildContext for tool construction' directly and clearly summarizes the main change: introducing a new context struct for tool construction.
Description check ✅ Passed The pull request description provides a comprehensive overview with a summary, motivation, and detailed changes, exceeding the minimal template requirements.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/tool-build-context

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/reloaded-code-agents/src/path/resolver.rs (1)

80-82: 💤 Low value

Documentation inconsistency: build_context does not contain permission config.

The doc comment states build_context contains "permission config" but ToolBuildContext only holds the permission: Option<&Ruleset>, not the IndexMap<String, PermissionRule> config which is passed as a separate parameter. Consider updating to:

-/// - `build_context` - [`ToolBuildContext`] containing permission config and
-///   canonicalized workspace root.
+/// - `build_context` - [`ToolBuildContext`] containing the canonicalized workspace root
+///   and optional permission ruleset.
+/// - `config` - Permission config map used to look up tool-specific rules.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/reloaded-code-agents/src/path/resolver.rs` around lines 80 - 82, The doc
comment for the function is incorrect: it claims `build_context` contains the
"permission config" but `ToolBuildContext` only holds `permission:
Option<&Ruleset>` while the actual permission rules map is passed separately
(e.g. `permission_config: &IndexMap<String, PermissionRule>`). Update the
comment to state that `build_context` provides an optional `Ruleset` reference
(via `ToolBuildContext`) and that the canonical permission rules map is supplied
by the separate `permission_config` parameter (mention `PermissionRule` and
`Ruleset`), so callers understand which symbol holds the full ruleset vs the
per-tool optional rules.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/reloaded-code-agents/src/path/resolver.rs`:
- Around line 80-82: The doc comment for the function is incorrect: it claims
`build_context` contains the "permission config" but `ToolBuildContext` only
holds `permission: Option<&Ruleset>` while the actual permission rules map is
passed separately (e.g. `permission_config: &IndexMap<String, PermissionRule>`).
Update the comment to state that `build_context` provides an optional `Ruleset`
reference (via `ToolBuildContext`) and that the canonical permission rules map
is supplied by the separate `permission_config` parameter (mention
`PermissionRule` and `Ruleset`), so callers understand which symbol holds the
full ruleset vs the per-tool optional rules.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a787738c-40da-4dce-8b47-b1651bd773c9

📥 Commits

Reviewing files that changed from the base of the PR and between 72ff2b3 and 97cd01d.

📒 Files selected for processing (4)
  • src/reloaded-code-agents/src/path/resolver.rs
  • src/reloaded-code-core/src/lib.rs
  • src/reloaded-code-core/src/tool_context/mod.rs
  • src/reloaded-code-serdesai/src/agent_runtime/build.rs

…sions through tool construction

- Add ToolBuildContext struct in reloaded-code-core with canonicalized workspace root and optional permission ruleset
- Refactor build_resolver_for_tool to accept &ToolBuildContext instead of separate config and workspace_root parameters
- Update reloaded-code-agents resolver and tests to use new context
- Update reloaded-code-serdesai runtime to create one context before tool construction loop
@Sewer56 Sewer56 force-pushed the feat/tool-build-context branch from 97cd01d to 6a58235 Compare May 29, 2026 20:59
@Sewer56 Sewer56 merged commit d111e61 into main May 29, 2026
19 checks passed
@Sewer56 Sewer56 deleted the feat/tool-build-context branch May 29, 2026 21:00
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