Skip to content

feat: implement JIT Tools RAG injection with SubAgent discovery and cache#3274

Closed
dahai9 wants to merge 3 commits intozeroclaw-labs:masterfrom
dahai9:feat/tools-rag-cache-clean
Closed

feat: implement JIT Tools RAG injection with SubAgent discovery and cache#3274
dahai9 wants to merge 3 commits intozeroclaw-labs:masterfrom
dahai9:feat/tools-rag-cache-clean

Conversation

@dahai9
Copy link
Copy Markdown

@dahai9 dahai9 commented Mar 12, 2026

Summary

Describe this PR in 2-5 bullets:

  • Base branch target (master for all contributions): master
  • Problem: The original cherry-pick for fcc5de41 had heavy merge conflicts with the newly refactored master branch.
  • Why it matters: Tool RAG is critical for injecting dynamically discovered subagents to avoid context limits.
  • What changed: Re-implemented the JIT Tools RAG integration from scratch atop the modern origin/master. Added fields to schema.rs, integrated initialization into start_channels(), and modified run_tool_call_loop parameters to support subset filtering via ToolRagIndex.
  • What did not change (scope boundary): Did not change the core RAG chunking logic inside tool_rag.rs.

Label Snapshot (required)

  • Risk label (risk: low|medium|high): risk: medium
  • Size label (size: XS|S|M|L|XL, auto-managed/read-only):
  • Scope labels (core|agent|channel|config|cron|daemon|doctor|gateway|health|heartbeat|integration|memory|observability|onboard|provider|runtime|security|service|skillforge|skills|tool|tunnel|docs|dependencies|ci|tests|scripts|dev, comma-separated): config, tool, agent, channel
  • Module labels (<module>: <component>, for example channel: telegram, provider: kimi, tool: shell): tool: rag
  • Contributor tier label (trusted contributor|experienced contributor|principal contributor|distinguished contributor, auto-managed/read-only; author merged PRs >=5/10/20/50):
  • If any auto-label is incorrect, note requested correction:

Change Metadata

  • Change type (bug|feature|refactor|docs|security|chore): feature
  • Primary scope (runtime|provider|channel|memory|security|ci|docs|multi): multi

Linked Issue

  • Closes #
  • Related #
  • Depends on # (if stacked)
  • Supersedes # (if replacing older PR)

Supersede Attribution (required when Supersedes # is used)

  • Superseded PRs + authors (#<pr> by @<author>, one per line):
  • Integrated scope by source PR (what was materially carried forward):
  • Co-authored-by trailers added for materially incorporated contributors? (Yes/No)
  • If No, explain why (for example: inspiration-only, no direct code/design carry-over):
  • Trailer format check (separate lines, no escaped \n): (Pass/Fail)

Validation Evidence (required)

Commands and result summary:

cargo fmt --all -- --check
cargo clippy --all-targets -- -D warnings
cargo test
  • Evidence provided (test/log/trace/screenshot/perf): Standard test pipeline executed locally successfully.
  • If any command is intentionally skipped, explain why:

Security Impact (required)

  • New permissions/capabilities? (Yes/No): No
  • New external network calls? (Yes/No): No
  • Secrets/tokens handling changed? (Yes/No): No
  • File system access scope changed? (Yes/No): No
  • If any Yes, describe risk and mitigation:

Privacy and Data Hygiene (required)

  • Data-hygiene status (pass|needs-follow-up): pass
  • Redaction/anonymization notes:
  • Neutral wording confirmation (use ZeroClaw/project-native labels if identity-like wording is needed): pass

Compatibility / Migration

  • Backward compatible? (Yes/No): Yes
  • Config/env changes? (Yes/No): Yes
  • Migration needed? (Yes/No): No
  • If yes, exact upgrade steps:

i18n Follow-Through (required when docs or user-facing wording changes)

  • i18n follow-through triggered? (Yes/No): No
  • If Yes, locale navigation parity updated in README*, docs/README*, and docs/SUMMARY.md for supported locales (en, zh-CN, ja, ru, fr, vi)? (Yes/No)
  • If Yes, localized runtime-contract docs updated where equivalents exist (minimum for fr/vi: commands-reference, config-reference, troubleshooting)? (Yes/No/N.A.)
  • If Yes, Vietnamese canonical docs under docs/i18n/vi/** synced and compatibility shims under docs/*.vi.md validated? (Yes/No/N.A.)
  • If any No/N.A., link follow-up issue/PR and explain scope decision:

Human Verification (required)

What was personally validated beyond CI:

  • Verified scenarios: Cargo checks for pipeline argument mismatches. Tests running with empty RAG indices via default configs.
  • Edge cases checked: Addressed multimodal loops, interactive tools loop, and cli tests default None threading.
  • What was not verified:

Side Effects / Blast Radius (required)

  • Affected subsystems/workflows: Tools Registry, Agent Execution Loop
  • Potential unintended effects: Tools failure if dynamically filtering removes essential base capabilities.
  • Guardrails/monitoring for early detection: RAG relies on semantic thresholds.

Agent Collaboration Notes (recommended)

  • Agent tools used (if any):
  • Workflow/plan summary (if any):
  • Verification focus:
  • Confirmation: naming + architecture boundaries followed (AGENTS.md + CONTRIBUTING.md):

Rollback Plan (required)

  • Fast rollback command/path: Revert commit
  • Feature flags or config toggles (if any): disable tools_injection_mode = "rag", set back to "full"
  • Observable failure symptoms:

Risks and Mitigations

List real risks in this PR (or write None).

  • Risk: High retrieval threshold omits essential tools during long multi-turn execution.
    • Mitigation: tools_rag_threshold and tools_rag_core_set exist as config variables to manually bypass semantic failure loops.

@theonlyhennygod
Copy link
Copy Markdown
Collaborator

Closing as stale — this PR has had no activity for over 2 weeks and is significantly behind master. If you'd like to continue this work, feel free to reopen with a fresh rebase against current master. Thanks for the contribution!

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.

2 participants