Skip to content

feat(agent): expose agent library surface#3383

Merged
senamakel merged 3 commits into
tinyhumansai:mainfrom
senamakel:issue/3372-expose-an-agent-library-and-explicit-sub
Jun 4, 2026
Merged

feat(agent): expose agent library surface#3383
senamakel merged 3 commits into
tinyhumansai:mainfrom
senamakel:issue/3372-expose-an-agent-library-and-explicit-sub

Conversation

@senamakel

@senamakel senamakel commented Jun 4, 2026

Copy link
Copy Markdown
Member

Summary

  • Added a safe agent.list_definitions controller surface backed by the Rust AgentDefinitionRegistry, omitting prompt bodies and registry paths.
  • Added an Intelligence Agents Library panel with loading, error, empty, and success states plus localized copy across supported locales.
  • Added explicit one-off agent task launching from the library, using an @agent:<id> routing hint and thread metadata.
  • Added focused Rust, JSON-RPC, service, panel, and Intelligence task-tab coverage.

Problem

  • OpenHuman already has registry-driven agent definitions, but users could not browse safe agent metadata or intentionally select a named worker.
  • The app relied on hidden orchestrator delegation, leaving model hints, tool scope, read/write capability, and subagent relationships invisible to users.

Solution

  • agent.list_definitions now 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.
  • The Intelligence task surface now includes an Agents Library card list with copy-id and one-off run actions.
  • Running a one-off task creates a task thread, records explicitAgentId metadata, and sends a prompt prefixed with @agent:<id> so explicit user selection can disambiguate routing.
  • The about-app capability catalog now includes the agent library feature.

Submission Checklist

If a section does not apply to this change, mark the item as N/A with a one-line reason. Do not delete items.

  • Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy
  • Diff coverage ≥ 80% — changed lines (Vitest + cargo-llvm-cov merged via 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.
  • Coverage matrix updated — N/A: this adds a surfaced capability and focused tests, but no existing matrix row maps to the agent-definition library surface.
  • All affected feature IDs from the matrix are listed in the PR description under ## Related — N/A: no matrix feature ID applies.
  • No new external network dependencies introduced (mock backend used per Testing Strategy)
  • Manual smoke checklist updated if this touches release-cut surfaces (docs/RELEASE-MANUAL-SMOKE.md) — N/A: not a release-cut smoke surface.
  • Linked issue closed via Closes #NNN in the ## Related section

Impact

  • Desktop app UI: Intelligence now exposes a browsable Agents Library.
  • Rust core/API: adds a safe registry-backed metadata method through the controller registry, without exposing prompt bodies.
  • Security/privacy: prompt bodies and definition paths remain omitted from the new display endpoint; no secrets or PII are logged.
  • Compatibility: natural-language delegation remains unchanged; explicit selection adds a structured hint path.

Related


AI Authored PR Metadata (required for Codex/Linear PRs)

Keep this section for AI-authored PRs. For human-only PRs, mark each field N/A.

Linear Issue

  • Key: N/A
  • URL: N/A

Commit & Branch

  • Branch: issue/3372-expose-an-agent-library-and-explicit-sub
  • Commit SHA: a9b89d930

Validation Run

  • pnpm --filter openhuman-app format:check (also passed in pre-push hook)
  • pnpm typecheck (cd app && pnpm typecheck is not defined in the app package; ran cd app && pnpm compile, and pre-push ran root pnpm compile)
  • Focused tests: 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:unit
  • Rust fmt/check (if changed): cargo 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_agents
  • Tauri fmt/check (if changed): cargo check --manifest-path app/src-tauri/Cargo.toml (also passed in pre-push hook)

Validation Blocked

  • command: cd app && pnpm typecheck

  • error: app package has no typecheck script (Command "typecheck" not found); cd app && pnpm compile passed instead.

  • impact: no TypeScript validation gap; compile is the app package's tsc --noEmit script and pre-push also ran root pnpm compile.

  • command: cargo test --manifest-path Cargo.toml

  • error: 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

  • Intended behavior change: users can browse safe agent definitions and explicitly launch a one-off task with a named agent from Intelligence.
  • User-visible effect: Intelligence shows an Agents Library with read-only/write-capable badges, tool/model/subagent chips, copy-id, and run-task actions.

Parity Contract

  • Legacy behavior preserved: natural-language orchestrator delegation and existing agent registry methods are unchanged.
  • Guard/fallback/dispatch parity checks: new method is registered through the controller registry and covered by schema/controller tests plus JSON-RPC E2E.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): none found for this head branch
  • Canonical PR: this PR
  • Resolution (closed/superseded/updated): N/A

Summary by CodeRabbit

  • New Features

    • Introduced Agents Library panel for discovering and browsing available agents with metadata display
    • Enabled running tasks with explicitly selected agents
    • Added agent ID copy-to-clipboard functionality with visual confirmation
  • Internationalization

    • Added full translations across 12 languages for Agents Library feature
  • Tests

    • Added comprehensive test coverage for new agent library components and APIs

@senamakel senamakel requested a review from a team June 4, 2026 15:55
@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

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

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 @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: 91b3f1a8-8334-4cb2-a846-ce938995a5c4

📥 Commits

Reviewing files that changed from the base of the PR and between dee49fc and 73bf7e9.

📒 Files selected for processing (18)
  • app/src/components/intelligence/AgentsLibraryPanel.test.tsx
  • app/src/components/intelligence/AgentsLibraryPanel.tsx
  • app/src/lib/i18n/ar.ts
  • app/src/lib/i18n/bn.ts
  • app/src/lib/i18n/de.ts
  • app/src/lib/i18n/en.ts
  • app/src/lib/i18n/es.ts
  • app/src/lib/i18n/fr.ts
  • app/src/lib/i18n/hi.ts
  • app/src/lib/i18n/id.ts
  • app/src/lib/i18n/it.ts
  • app/src/lib/i18n/ko.ts
  • app/src/lib/i18n/pl.ts
  • app/src/lib/i18n/pt.ts
  • app/src/lib/i18n/ru.ts
  • app/src/lib/i18n/zh-CN.ts
  • app/src/services/api/agentLibraryApi.test.ts
  • app/src/services/api/agentLibraryApi.ts
📝 Walkthrough

Walkthrough

This 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.

Changes

Agent Library & Explicit Task Selection

Layer / File(s) Summary
Backend types and library module structure
src/openhuman/agent/library/types.rs, src/openhuman/agent/library/mod.rs, src/openhuman/agent/mod.rs
New Rust types define safe display metadata (AgentDefinitionSource, AgentDefinitionModel, AgentDefinitionDisplay) and establish a public library module exporting the metadata functions and types.
Agent metadata projection logic
src/openhuman/agent/library/ops.rs
Implements mapping from full AgentDefinition to safe display fields: model kind/value conversion, tool name aggregation (named + extra, minus disallowed), subagent id extraction, and capability flags (write_capable, can_run_as_user_facing_worker) inferred via sandbox mode and heuristic write-verb detection. Unit test validates field presence and JSON serialization omits prompt bodies.
RPC schema and controller integration
src/openhuman/agent/schemas.rs
Updates list_definitions schema documentation to reflect safe display metadata and calls agent::library::list_definition_metadata() in the handler instead of exposing raw definitions.
TypeScript API wrapper and types
app/src/services/api/agentLibraryApi.ts, app/src/services/api/agentLibraryApi.test.ts
Introduces agentLibraryApi.listDefinitions() function that calls the RPC with debug logging and exports the TypeScript type mirrors. Tests verify RPC method/params and empty-array fallback behavior.
AgentsLibraryPanel component
app/src/components/intelligence/AgentsLibraryPanel.tsx, app/src/components/intelligence/AgentsLibraryPanel.test.tsx
Renders a browsable agent library with loading/error/empty states, per-agent cards showing metadata (name, id, model label, capability chips for tier/permissions/tool counts), clipboard copy with transient feedback, per-agent prompt drafts, and task-run callback with guards against concurrent/empty-prompt runs. Five test cases cover state transitions, rendering safety, filtering, callback wiring, and clipboard behavior.
Explicit agent task invocation in IntelligenceTasksTab
app/src/components/intelligence/IntelligenceTasksTab.tsx, app/src/components/intelligence/__tests__/IntelligenceTasksTab.test.tsx
Adds runningAgentId state, buildExplicitAgentPrompt() to format @agent:<id> directives, and handleRunAgentTask() callback that creates labeled "AGENT_TASK" threads with agent/library context, appends messages with explicit-agent metadata, dispatches Redux actions, and calls chatSend. Wires AgentsLibraryPanel into the tab with callback and disabled-state management. Test extends mocks and verifies thread/message/send wiring for library agent selection.
Vitest and E2E test coverage
tests/json_rpc_e2e.rs
Extends E2E test to call openhuman.agent_list_definitions and assert the returned researcher definition includes expected metadata fields (display name, tools, capability counts/flags) while omitting sensitive prompt data.
Internationalization and capability catalog
app/src/lib/i18n/*.ts, src/openhuman/about_app/catalog_data.rs, src/openhuman/about_app/catalog_tests.rs
Adds intelligence.agents.* translation keys across 12+ languages for agent library UI (titles, states, capability labels, pluralization, actions) and registers intelligence.agent_library as a Beta capability with DERIVED_TO_BACKEND privacy scope.

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
Loading

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 handleRunAgentTask, and comprehensive i18n coverage across 12+ languages. However, changes are well-scoped, consistently patterned (especially i18n), and supported by unit and E2E tests.

Possibly related PRs

  • tinyhumansai/openhuman#3279: Both PRs modify IntelligenceTasksTab's agent-task launch flow by creating labeled "AGENT_TASK" threads with agent context and appending user messages before navigating to chat and calling chatSend; the agent-library run path directly parallels the task-launch mechanics.
  • tinyhumansai/openhuman#2731: Both PRs update Polish i18n via app/src/lib/i18n/pl.ts; this PR adds intelligence.agents.* translations while the retrieved PR restructures Polish locale coverage.

Suggested labels

feature, agent, rust-core

Suggested reviewers

  • graycyrus
  • sanil-23
  • oxoxDev

Poem

🐰 A library of agents now blooms,
Each one ready to fill its room—
Browse their talents, pick the right one,
Run a task, watch the work get done!
Explicit choice beats hidden ways,
Your agents shine in brighter days. ✨

🚥 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 'feat(agent): expose agent library surface' directly summarizes the main change—introducing a safe controller endpoint and UI components for an agent library.
Linked Issues check ✅ Passed All major coding objectives from #3372 are met: agent.list_definitions endpoint registered [#3372]; Agents Library UI panel with localized strings added [#3372]; explicit agent task invocation via @agent: wiring implemented [#3372]; read-only/write-capable distinction rendered [#3372]; Rust and Vitest tests added [#3372].
Out of Scope Changes check ✅ Passed All changes align with #3372 objectives: Rust agent library module, controller schema, UI panel, Intelligence tab integration, API service, i18n translations, and tests are all in scope.

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


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

@coderabbitai coderabbitai Bot added feature Net-new user-facing capability or product behavior. rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure. agent Built-in agents, prompts, orchestration, and agent runtime in src/openhuman/agent/. labels Jun 4, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
src/openhuman/agent/library/ops.rs (1)

9-30: ⚡ Quick win

Add 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

📥 Commits

Reviewing files that changed from the base of the PR and between e40fec9 and dee49fc.

📒 Files selected for processing (28)
  • app/src/components/intelligence/AgentsLibraryPanel.test.tsx
  • app/src/components/intelligence/AgentsLibraryPanel.tsx
  • app/src/components/intelligence/IntelligenceTasksTab.tsx
  • app/src/components/intelligence/__tests__/IntelligenceTasksTab.test.tsx
  • app/src/lib/i18n/ar.ts
  • app/src/lib/i18n/bn.ts
  • app/src/lib/i18n/de.ts
  • app/src/lib/i18n/en.ts
  • app/src/lib/i18n/es.ts
  • app/src/lib/i18n/fr.ts
  • app/src/lib/i18n/hi.ts
  • app/src/lib/i18n/id.ts
  • app/src/lib/i18n/it.ts
  • app/src/lib/i18n/ko.ts
  • app/src/lib/i18n/pl.ts
  • app/src/lib/i18n/pt.ts
  • app/src/lib/i18n/ru.ts
  • app/src/lib/i18n/zh-CN.ts
  • app/src/services/api/agentLibraryApi.test.ts
  • app/src/services/api/agentLibraryApi.ts
  • src/openhuman/about_app/catalog_data.rs
  • src/openhuman/about_app/catalog_tests.rs
  • src/openhuman/agent/library/mod.rs
  • src/openhuman/agent/library/ops.rs
  • src/openhuman/agent/library/types.rs
  • src/openhuman/agent/mod.rs
  • src/openhuman/agent/schemas.rs
  • tests/json_rpc_e2e.rs

Comment thread app/src/components/intelligence/AgentsLibraryPanel.tsx Outdated
Comment thread app/src/components/intelligence/AgentsLibraryPanel.tsx
Comment thread app/src/components/intelligence/AgentsLibraryPanel.tsx
Comment thread app/src/services/api/agentLibraryApi.ts
@senamakel senamakel merged commit 1083c31 into tinyhumansai:main Jun 4, 2026
19 checks passed
senamakel added a commit to senamakel/openhuman that referenced this pull request Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Built-in agents, prompts, orchestration, and agent runtime in src/openhuman/agent/. feature Net-new user-facing capability or product behavior. rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose an agent library and explicit subagent invocation surface

1 participant