Skip to content

Conversation

@birdayz
Copy link
Contributor

@birdayz birdayz commented Dec 18, 2025

What

Add UI for configuring subagents in agent creation and edit forms, including proto extension for subagent descriptions. Subagents delegate specialized tasks and inherit provider/model from parent agent.

Fix service account visibility regression on AI agent and MCP server detail pages.

Why

Proto f8aab16 added subagent support but lacked UI implementation. Agents need ability to spawn specialized subagents with custom system prompts, descriptions, and filtered tool access without separate provider/model configuration overhead.

Service account sections disappeared from detail pages after tag key rename in d9e8a31. Pages checked hardcoded 'service_account_id' instead of using CLOUD_MANAGED_TAG_KEYS constant.

Implementation details

Proto changes:

  • Added Subagent.description field (field 3, max 256 chars)
  • Description used by parent for routing decisions and context management
  • Field numbers preserved for backward compatibility

Service account fix:

  • AI agent and MCP detail pages now use CLOUD_MANAGED_TAG_KEYS.SERVICE_ACCOUNT_ID constant
  • Restores visibility of service account metadata and role bindings for operators

@github-actions
Copy link
Contributor

github-actions bot commented Dec 18, 2025

The latest Buf updates on your PR. Results from workflow Buf CI / validate (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedDec 19, 2025, 1:10 PM

Comment on lines 472 to 478
if (subagent.name.trim()) {
const subagentMcpMap: Record<string, { id: string }> = {};
for (const serverId of subagent.selectedMcpServers) {
subagentMcpMap[serverId] = create(AIAgent_MCPServerSchema, { id: serverId });
}

subagentsMap[subagent.name.trim()] = create(AIAgent_SubagentSchema, {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's trim the subagent name and declare a new variable to reuse in the map.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Trimmed name once and reused variable.

@birdayz birdayz marked this pull request as ready for review December 18, 2025 14:03
Agents now support subagents - specialized delegates that inherit provider/model from parent while maintaining their own system prompt and MCP server access.

UI changes:
- New SubagentConfigSection component using accordion pattern
- Integrated into both create and edit flows
- Subagents auto-expand on add for immediate editing
- Bidirectional proto map conversion (form array <-> proto map)
- Validation: name pattern ^[A-Za-z0-9_-]+$, unique names, min 10 char prompts

Each subagent gets:
- Unique name (routing key)
- Custom system prompt
- Filtered MCP server access

Proto field 15 (subagents map) now fully wired through UI stack.
Proto changes:
- Added description field to Subagent message (field 3, max 256 chars)
- Field numbers preserved for backward compatibility

UI changes:
- Added description textarea to SubagentConfigSection component
- Added description field to edit mode in AIAgentConfigurationTab
- Added helper text explaining usage:
  * Parent agent uses description to decide when to invoke subagent
  * Used for context management - parent provides context when starting subagent
  * Subagent maintains its own context

Wired through full stack: proto -> schema validation -> form components -> proto conversion.
Clicking MCP server card in subagent was incorrectly toggling root agent's checkbox when the same server appeared in both contexts.

Root cause: checkbox IDs were not unique across contexts (root vs subagent). Label htmlFor pointed to first matching ID in DOM, causing cross-context activation.

Fix: Add idPrefix prop to MCPServerCardList to namespace checkbox IDs:
- Root agent: "mcp-server-root-{serverId}"
- Subagents: "mcp-server-subagent-{index}-{serverId}"

Clicking checkbox directly worked because onCheckedChange handler had correct scope. Clicking card/label triggered wrong checkbox via ID collision.
Trim subagent name once and reuse variable to avoid redundant
string operations. Improves code clarity and eliminates duplicate
trim() calls on same input value.
Edit mode lacked validation, allowing invalid data to reach the backend.
Added comprehensive validation matching create mode Zod schema:

- Name required, max 64 chars, alphanumeric/hyphen/underscore only
- Duplicate name detection (prevents silent data loss in proto map)
- System prompt minimum 10 chars
- Description max 256 chars (optional)

All validation errors surface as toast notifications before save attempt.
Prevents backend failures and improves UX.
When tag naming changed from 'service_account_id' to 'rp_cloud_service_account_id'
in commit d9e8a31, the detail pages still checked for the old hardcoded key instead
of using CLOUD_MANAGED_TAG_KEYS.SERVICE_ACCOUNT_ID constant.

This caused service account sections to disappear from both AI agent and MCP server
configuration tabs even when service accounts existed.

Update both pages to use the constant for tag lookup. This restores visibility
of service account metadata and role bindings for operators.
@birdayz birdayz merged commit db2bbaa into master Dec 19, 2025
16 checks passed
@birdayz birdayz deleted the jb/subagent-ui branch December 19, 2025 13:29
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.

3 participants