feat(agent): expose agent library surface#3383
Conversation
|
Warning Review limit reached
More reviews will be available in 75 minutes and 43 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 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (18)
📝 WalkthroughWalkthroughThis PR adds an agent library surface to OpenHuman, exposing safe agent definition metadata through a new RPC endpoint and UI panel that lets users browse, understand, and explicitly invoke individual agents for focused tasks without relying solely on orchestrator delegation. ChangesAgent Library & Explicit Task Selection
Sequence Diagram(s)sequenceDiagram
participant User
participant IntelligenceTab
participant AgentsLibraryPanel
participant agentLibraryApi
participant RPC
participant AgentRegistry
participant Chat
User->>IntelligenceTab: view Intelligence tab
IntelligenceTab->>AgentsLibraryPanel: render panel
AgentsLibraryPanel->>agentLibraryApi: listDefinitions()
agentLibraryApi->>RPC: call openhuman.agent_list_definitions
RPC->>AgentRegistry: list_definition_metadata()
AgentRegistry-->>RPC: [AgentDefinitionDisplay...]
RPC-->>agentLibraryApi: definitions array
agentLibraryApi-->>AgentsLibraryPanel: [agent1, agent2, ...]
AgentsLibraryPanel-->>User: render agent cards with chips
User->>AgentsLibraryPanel: select agent, enter task, click run
AgentsLibraryPanel->>IntelligenceTab: onRunAgentTask(agent, prompt)
IntelligenceTab->>IntelligenceTab: buildExplicitAgentPrompt(`@agent`:id)
IntelligenceTab->>IntelligenceTab: createNewThread(AGENT_TASK)
IntelligenceTab->>Chat: navigate + chatSend with explicit agent metadata
Chat-->>User: open chat with agent context
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes The PR spans frontend and backend with new types, logic projection, RPC integration, UI component, and cross-file coordination. Complexity arises from the capability flag inference logic (sandbox mode + write-verb heuristics), promise-based callback chaining in Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
src/openhuman/agent/library/ops.rs (1)
9-30: ⚡ Quick winAdd rustdoc on the public projection ops.
Please document the safe-display contract directly on the exported functions so downstream callers have an explicit, local guarantee about omitted fields (prompt bodies/paths) and initialization behavior.
✍️ Suggested doc comments
+/// Returns UI-safe metadata for all registered agent definitions. +/// +/// This projection intentionally omits prompt bodies and registry file paths. pub async fn list_definition_metadata() -> Result<Vec<AgentDefinitionDisplay>, String> { @@ +/// Projects a single internal `AgentDefinition` into a safe display payload. pub fn metadata_from_definition(def: &AgentDefinition) -> AgentDefinitionDisplay {As per coding guidelines: Ensure all new/changed Rust behavior ships with matching rustdoc / code comments and updates to AGENTS.md or architecture docs.
🤖 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/openhuman/agent/library/ops.rs` around lines 9 - 30, Add rustdoc comments to the public projection functions to state the "safe-display" contract and initialization behavior: document on list_definition_metadata that it may initialize AgentDefinitionRegistry (calls config_rpc::load_config_with_timeout and AgentDefinitionRegistry::init_global) and that callers can get an Err on init failure; also document that metadata_from_definition returns an AgentDefinitionDisplay that intentionally omits sensitive/large fields (e.g., prompt bodies/paths) and list exactly which fields are redacted so downstream callers know what's safe to show. Reference the exported symbols list_definition_metadata and metadata_from_definition in the comments and keep the wording concise and prescriptive (what is omitted and the init side-effect).
🤖 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.
Inline comments:
In `@app/src/components/intelligence/AgentsLibraryPanel.tsx`:
- Around line 89-94: The handleCopy function sets the "copied" UI even when
navigator.clipboard?.writeText resolves to undefined because optional chaining
can short-circuit; fix by explicitly checking clipboard availability before
attempting to write and only setCopiedId after a successful writeText call.
Concretely, in handleCopy, guard with if (!navigator.clipboard || typeof
navigator.clipboard.writeText !== "function") return (or optionally fallback),
then await navigator.clipboard.writeText(id) inside the try and only call
setCopiedId(id) after that promise resolves; keep the existing timeout cleanup
and catch block to handle errors.
- Around line 208-216: The task input in AgentsLibraryPanel relies on
placeholder text and lacks an accessible name; add one by giving the input a
stable id (e.g., `task-input-${agent.id}`) and either rendering a
visually-hidden <label> that uses htmlFor that id or adding an explicit
aria-label (e.g., aria-label={t('intelligence.agents.taskLabel')}) on the input;
keep the current onChange handler (setDrafts) and value (draft) unchanged and
ensure the label text is localized via the existing t(...) function.
- Around line 15-18: The modelLabel function contains a hard-coded user-visible
string 'inherit' that must be localized according to coding guidelines. Modify
the modelLabel function to accept the translation function as a parameter
(obtained from useT() in the calling component), then use it to localize the
'inherit' string by wrapping it with the translation function call. Update all
call sites of modelLabel to pass the translation function from useT(). Apply the
same localization fix to any other occurrences mentioned at lines 168-169.
In `@app/src/services/api/agentLibraryApi.ts`:
- Around line 35-40: The current code sets definitions = response?.definitions
?? [] but that can pass non-array truthy values; update the assignment in the
agent list call (the code around callCoreRpc and the definitions variable) to
enforce an array, e.g. use Array.isArray(response?.definitions) ?
response.definitions : [] so any non-array is replaced with an empty array
before logging/returning; keep the callCoreRpc invocation and
log('[agent-library] listDefinitions exit count=%d', definitions.length) as-is.
---
Nitpick comments:
In `@src/openhuman/agent/library/ops.rs`:
- Around line 9-30: Add rustdoc comments to the public projection functions to
state the "safe-display" contract and initialization behavior: document on
list_definition_metadata that it may initialize AgentDefinitionRegistry (calls
config_rpc::load_config_with_timeout and AgentDefinitionRegistry::init_global)
and that callers can get an Err on init failure; also document that
metadata_from_definition returns an AgentDefinitionDisplay that intentionally
omits sensitive/large fields (e.g., prompt bodies/paths) and list exactly which
fields are redacted so downstream callers know what's safe to show. Reference
the exported symbols list_definition_metadata and metadata_from_definition in
the comments and keep the wording concise and prescriptive (what is omitted and
the init side-effect).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 71bdbfff-c84d-4df2-a635-76f7c544acbb
📒 Files selected for processing (28)
app/src/components/intelligence/AgentsLibraryPanel.test.tsxapp/src/components/intelligence/AgentsLibraryPanel.tsxapp/src/components/intelligence/IntelligenceTasksTab.tsxapp/src/components/intelligence/__tests__/IntelligenceTasksTab.test.tsxapp/src/lib/i18n/ar.tsapp/src/lib/i18n/bn.tsapp/src/lib/i18n/de.tsapp/src/lib/i18n/en.tsapp/src/lib/i18n/es.tsapp/src/lib/i18n/fr.tsapp/src/lib/i18n/hi.tsapp/src/lib/i18n/id.tsapp/src/lib/i18n/it.tsapp/src/lib/i18n/ko.tsapp/src/lib/i18n/pl.tsapp/src/lib/i18n/pt.tsapp/src/lib/i18n/ru.tsapp/src/lib/i18n/zh-CN.tsapp/src/services/api/agentLibraryApi.test.tsapp/src/services/api/agentLibraryApi.tssrc/openhuman/about_app/catalog_data.rssrc/openhuman/about_app/catalog_tests.rssrc/openhuman/agent/library/mod.rssrc/openhuman/agent/library/ops.rssrc/openhuman/agent/library/types.rssrc/openhuman/agent/mod.rssrc/openhuman/agent/schemas.rstests/json_rpc_e2e.rs
Summary
agent.list_definitionscontroller surface backed by the RustAgentDefinitionRegistry, omitting prompt bodies and registry paths.@agent:<id>routing hint and thread metadata.Problem
Solution
agent.list_definitionsnow projects registry definitions into UI-safe display metadata: id, display name, when-to-use text, tier, model hint, direct tools, subagents, memory/profile flags, user-facing eligibility, write capability, and source.explicitAgentIdmetadata, and sends a prompt prefixed with@agent:<id>so explicit user selection can disambiguate routing.Submission Checklist
diff-cover) meet the gate enforced by.github/workflows/pr-ci.yml. Local merged coverage was not run; focused changed-line tests were added and CI will enforce the gate.## Related— N/A: no matrix feature ID applies.docs/RELEASE-MANUAL-SMOKE.md) — N/A: not a release-cut smoke surface.Closes #NNNin the## RelatedsectionImpact
Related
AI Authored PR Metadata (required for Codex/Linear PRs)
Linear Issue
Commit & Branch
issue/3372-expose-an-agent-library-and-explicit-suba9b89d930Validation Run
pnpm --filter openhuman-app format:check(also passed in pre-push hook)pnpm typecheck(cd app && pnpm typecheckis not defined in the app package; rancd app && pnpm compile, and pre-push ran rootpnpm compile)pnpm debug unit src/lib/i18n/__tests__/I18nContext.test.tsx src/lib/i18n/__tests__/coverage.test.ts src/services/api/agentLibraryApi.test.ts src/components/intelligence/AgentsLibraryPanel.test.tsx src/components/intelligence/__tests__/IntelligenceTasksTab.test.tsx --verbose;cd app && pnpm test:unitcargo fmt --manifest-path Cargo.toml;cargo check --manifest-path Cargo.toml; focused Rust tests for agent library/schema/catalog;cargo test --manifest-path Cargo.toml --test json_rpc_e2e json_rpc_agent_registry_manages_defaults_and_custom_agentscargo check --manifest-path app/src-tauri/Cargo.toml(also passed in pre-push hook)Validation Blocked
command:cd app && pnpm typecheckerror:app package has notypecheckscript (Command "typecheck" not found);cd app && pnpm compilepassed instead.impact:no TypeScript validation gap;compileis the app package'stsc --noEmitscript and pre-push also ran rootpnpm compile.command:cargo test --manifest-path Cargo.tomlerror:one order-dependent untouched memory-tree test failed in the full suite:openhuman::memory_tree::tree::rpc::tests::pipeline_status_reports_chunk_aggregates_after_ingest; isolated rerun of the same test passed.impact:not tied to this diff; changed Rust surfaces were covered by focused unit tests and JSON-RPC E2E.Behavior Changes
Parity Contract
Duplicate / Superseded PR Handling
Summary by CodeRabbit
New Features
Internationalization
Tests