Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

1.4 KB
Raw Blame
import type { InjectedToolManifest } from '@lobechat/types';

import { AgentManagementManifest } from './manifest';
import { AgentManagementApiName, AgentManagementIdentifier } from './types';

const callAgentSystemRole = `You have a callAgent tool to delegate tasks to other AI agents.

<execution_guide>
### Synchronous Call
callAgent(agentId, instruction) — agent responds directly in conversation.

### Background Call
callAgent(agentId, instruction, runInBackground: true) — returns at once; the agent's reply arrives later as a message from that agent. Do not poll for it.
</execution_guide>`;

/**
 * Create a slim manifest containing only the callAgent API.
 * Used when @mentioned agents need delegation without the full Agent Management toolset.
 */
export const createCallAgentManifest = (): InjectedToolManifest => {
  const callAgentApi = AgentManagementManifest.api.find(
    (api) => api.name === AgentManagementApiName.callAgent,
  );

  if (!callAgentApi) {
    throw new Error('callAgent API not found in AgentManagementManifest');
  }

  return {
    api: [
      {
        description: callAgentApi.description,
        name: callAgentApi.name,
        parameters: callAgentApi.parameters,
      },
    ],
    identifier: AgentManagementIdentifier,
    meta: { description: 'Delegate tasks to other agents', title: 'Agent Management' },
    systemRole: callAgentSystemRole,
    type: 'builtin',
  };
};