Skip to content

fix: route agent tools through main-process proxy#349

Merged
ModerRAS merged 1 commit into
masterfrom
codex/fix-agent-empty-encoded-value
May 12, 2026
Merged

fix: route agent tools through main-process proxy#349
ModerRAS merged 1 commit into
masterfrom
codex/fix-agent-empty-encoded-value

Conversation

@ModerRAS

@ModerRAS ModerRAS commented May 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • stop LLMAgent from scanning the whole LLM assembly as local tools, so exported main-process tools are registered as proxy tools instead of being shadowed by incomplete child-process DI
  • forward ToolContext metadata through proxy tool calls so the main process can execute context-sensitive tools with the original chat/user/message ids
  • register OpenAIResponsesService in the LLMAgent service provider

Validation

  • dotnet test TelegramSearchBot.LLM.Test\TelegramSearchBot.LLM.Test.csproj --configuration Release --no-restore
  • dotnet test TelegramSearchBot.Test\TelegramSearchBot.Test.csproj --configuration Release --no-restore --filter "FullyQualifiedName~Agent"
  • dotnet build TelegramSearchBot.sln --configuration Release --no-restore

Summary by CodeRabbit

Release Notes

  • Tests

    • Added validation tests for service registration and initialization
    • Added tests for proxy tool context metadata forwarding
  • Bug Fixes

    • Improved proxy tool execution to properly forward context metadata to downstream services
    • Enhanced service configuration to ensure all required components are registered

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 12, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2cafce9d-22f0-45c7-8799-f575420d74b8

📥 Commits

Reviewing files that changed from the base of the PR and between dcd0727 and 631480b.

📒 Files selected for processing (4)
  • TelegramSearchBot.LLM.Test/Service/AI/LLM/AgentProcessToolRegistrationTests.cs
  • TelegramSearchBot.LLM.Test/Service/AI/LLM/McpToolHelperProxyTests.cs
  • TelegramSearchBot.LLM/Service/AI/LLM/McpToolHelper.cs
  • TelegramSearchBot.LLMAgent/LLMAgentProgram.cs

📝 Walkthrough

Walkthrough

This PR registers OpenAIResponsesService as a scoped DI service, implements context metadata injection for proxy tools (adding __chatId, __userId, __messageId to arguments), and adjusts tool discovery by removing FileToolService from the assembly list during initialization.

Changes

Agent Services & Proxy Tool Context

Layer / File(s) Summary
OpenAI Responses Service Registration
TelegramSearchBot.LLMAgent/LLMAgentProgram.cs, TelegramSearchBot.LLM.Test/Service/AI/LLM/AgentProcessToolRegistrationTests.cs
OpenAIResponsesService is registered as a scoped service in BuildServices. Test verifies the service is available in the built ServiceProvider.
Proxy Tool Context Metadata Injection
TelegramSearchBot.LLM/Service/AI/LLM/McpToolHelper.cs, TelegramSearchBot.LLM.Test/Service/AI/LLM/McpToolHelperProxyTests.cs
ExecuteRegisteredToolAsync clones string arguments into a case-insensitive dictionary and injects __chatId, __userId, __messageId from ToolContext before invoking the proxy tool executor. Test registers a proxy tool and verifies the forwarded metadata keys are present in the handler's arguments.
Tool Discovery Assembly Configuration
TelegramSearchBot.LLMAgent/LLMAgentProgram.cs
McpToolHelper.EnsureInitialized is called without FileToolService assembly in the provided assembly list, reducing the set of tool definitions discovered.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • ModerRAS/TelegramSearchBot#343: Adds OpenAIResponsesService and related wiring; this PR's service registration and test directly build on that foundation.
  • ModerRAS/TelegramSearchBot#269: Implements proxy tool registry and proxy-aware ExecuteRegisteredToolAsync; this PR extends that with context metadata injection.
  • ModerRAS/TelegramSearchBot#268: Modifies LLMAgentProgram startup and tool initialization; this PR adjusts the same assembly configuration in the opposite direction.

Poem

🐰 A proxy tool now carries context dear,
Injecting metadata loud and clear,
Chat ID, user, message in tow,
While OpenAI's responses steal the show.
~Rabbit's Registry of Requests 🎩✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% 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 'fix: route agent tools through main-process proxy' accurately describes the main change: routing agent tools through a main-process proxy rather than scanning locally, which is the core architectural fix in this PR.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-agent-empty-encoded-value

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.

@github-actions

Copy link
Copy Markdown
Contributor

PR Check Report

Summary

Test Results

Platform Status Details
Ubuntu Passed Tests passed, artifacts uploaded
Windows Passed Tests passed, artifacts uploaded

Code Quality

  • Code formatting check
  • Security vulnerability scan
  • Dependency analysis
  • Code coverage collection

Test Artifacts

  • Test results artifacts count: 2
  • Code coverage uploaded to Codecov

Links


This report is auto-generated by GitHub Actions

@ModerRAS ModerRAS merged commit d109c1f into master May 12, 2026
5 checks passed
@ModerRAS ModerRAS deleted the codex/fix-agent-empty-encoded-value branch May 12, 2026 15:27
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