Skip to main content

Agents

Interact with deployed AI agents programmatically. Agents are custom AI assistants built in Jabrod with tools, knowledge bases, and custom system prompts.

Chat with an Agent

Send a message to a deployed agent and get a response:
const result = await jabrod.agents.chat({
  agentId: 'your-agent-id',
  message: 'What can you help me with?'
});

console.log(result.message);
console.log('Model:', result.model);
console.log('RAG used:', result.ragUsed);

Multi-turn Conversations

Pass conversation history for context-aware follow-ups:
const history = [
  { role: 'user', content: 'What is our refund policy?' },
  { role: 'assistant', content: 'Our refund policy allows returns within 30 days...' }
];

const result = await jabrod.agents.chat({
  agentId: 'your-agent-id',
  message: 'What about international orders?',
  history
});

Fluent Builder API

Use the builder pattern for cleaner code:
const result = await jabrod.agents
  .chatBuilder('your-agent-id')
  .withMessage('Analyze the latest sales data')
  .withHistory(previousMessages)
  .execute();

Response Object

The agent chat response includes:
FieldTypeDescription
messagestringAgentโ€™s response text
modelstringModel used for generation
ragUsedbooleanWhether knowledge base context was used
ragSourcesarraySource chunks from the knowledge base
toolsUsedarrayTools the agent invoked
toolsAvailablestring[]Tools configured for the agent

Tool-Enabled Agents

Agents can have built-in tools (web search, calculator, code interpreter) and custom workflow tools:
const result = await jabrod.agents.chat({
  agentId: 'research-agent',
  message: 'Search for the latest AI news and summarize it'
});

if (result.toolsUsed) {
  for (const tool of result.toolsUsed) {
    console.log(`Tool: ${tool.tool}, Args:`, tool.args);
  }
}

Error Handling

Handle potential errors when communicating with agents:
try {
  const result = await jabrod.agents.chat({
    agentId: 'your-agent-id',
    message: 'Complex analysis task'
  });
} catch (error) {
  if (error instanceof JabrodError) {
    console.error('Agent Error:', error.message);
    console.error('Status Code:', error.status);
  } else {
    console.error('Unexpected Error:', error);
  }
}

Model Configuration

Agents are configured with specific models in the dashboard, but you can see which model responded:
const result = await jabrod.agents.chat({
  agentId: 'agent-123',
  message: 'Hello'
});

console.log(`Response generated using ${result.model}`);
// => Response generated using openai/gpt-4o-mini

Getting Agent IDs

You can find your agent ID in the Jabrod dashboard under Agents โ†’ Agent Settings, or in the agent URL after deployment.