feat(docs): document native tool calling support and update README to clarify standard and additional tools
This commit is contained in:
41
readme.md
41
readme.md
@@ -50,7 +50,6 @@ flowchart TB
|
||||
Shell["Shell"]
|
||||
Browser["Browser"]
|
||||
Deno["Deno"]
|
||||
JSON["JSON Validator"]
|
||||
end
|
||||
|
||||
Task --> Orchestrator
|
||||
@@ -100,7 +99,7 @@ await orchestrator.stop();
|
||||
|
||||
## Standard Tools
|
||||
|
||||
SmartAgent comes with six battle-tested tools out of the box:
|
||||
SmartAgent comes with five battle-tested tools out of the box via `registerStandardTools()`:
|
||||
|
||||
### 🗂️ FilesystemTool
|
||||
|
||||
@@ -231,12 +230,21 @@ By default, code runs **fully sandboxed with no permissions**. Permissions must
|
||||
</tool_call>
|
||||
```
|
||||
|
||||
## Additional Tools
|
||||
|
||||
### 📋 JsonValidatorTool
|
||||
|
||||
Validate and format JSON data. Perfect for agents to self-check their JSON output before completing tasks.
|
||||
|
||||
**Actions**: `validate`, `format`
|
||||
|
||||
```typescript
|
||||
import { JsonValidatorTool } from '@push.rocks/smartagent';
|
||||
|
||||
// Register the JSON validator tool (not included in registerStandardTools)
|
||||
orchestrator.registerTool(new JsonValidatorTool());
|
||||
```
|
||||
|
||||
```typescript
|
||||
// Validate JSON with required field checking
|
||||
<tool_call>
|
||||
@@ -330,6 +338,29 @@ const orchestrator = new DualAgentOrchestrator({
|
||||
|
||||
**Event Types**: `task_started`, `iteration_started`, `tool_proposed`, `guardian_evaluating`, `tool_approved`, `tool_rejected`, `tool_executing`, `tool_completed`, `task_completed`, `clarification_needed`, `max_iterations`, `max_rejections`
|
||||
|
||||
## 🔧 Native Tool Calling
|
||||
|
||||
For providers that support native tool calling (like Ollama with certain models), SmartAgent can use the provider's built-in tool calling API instead of XML parsing:
|
||||
|
||||
```typescript
|
||||
const orchestrator = new DualAgentOrchestrator({
|
||||
ollamaToken: 'http://localhost:11434', // Ollama endpoint
|
||||
defaultProvider: 'ollama',
|
||||
guardianPolicyPrompt: '...',
|
||||
|
||||
// Enable native tool calling
|
||||
useNativeToolCalling: true,
|
||||
});
|
||||
```
|
||||
|
||||
When `useNativeToolCalling` is enabled:
|
||||
- Tools are converted to JSON schema format automatically
|
||||
- The provider handles tool call parsing natively
|
||||
- Streaming still works with `[THINKING]` and `[OUTPUT]` markers for supported models
|
||||
- Tool calls appear as `toolName_actionName` (e.g., `json_validate`)
|
||||
|
||||
This is more efficient for models that support it and avoids potential XML parsing issues.
|
||||
|
||||
## Guardian Policy Examples
|
||||
|
||||
The Guardian's power comes from your policy. Here are battle-tested examples:
|
||||
@@ -401,6 +432,7 @@ interface IDualAgentOptions {
|
||||
perplexityToken?: string;
|
||||
groqToken?: string;
|
||||
xaiToken?: string;
|
||||
ollamaToken?: string; // URL for Ollama endpoint
|
||||
|
||||
// Use existing SmartAi instance (optional - avoids duplicate providers)
|
||||
smartAiInstance?: SmartAi;
|
||||
@@ -415,6 +447,9 @@ interface IDualAgentOptions {
|
||||
name?: string; // Agent system name
|
||||
verbose?: boolean; // Enable verbose logging
|
||||
|
||||
// Native tool calling
|
||||
useNativeToolCalling?: boolean; // Use provider's native tool calling API (default: false)
|
||||
|
||||
// Limits
|
||||
maxIterations?: number; // Max task iterations (default: 20)
|
||||
maxConsecutiveRejections?: number; // Abort after N rejections (default: 3)
|
||||
@@ -574,7 +609,7 @@ const orchestrator = new DualAgentOrchestrator({
|
||||
| `run(task, options?)` | Execute a task with optional images for vision |
|
||||
| `continueTask(input)` | Continue a task with user input |
|
||||
| `registerTool(tool)` | Register a custom tool |
|
||||
| `registerStandardTools()` | Register all built-in tools |
|
||||
| `registerStandardTools()` | Register all built-in tools (Filesystem, HTTP, Shell, Browser, Deno) |
|
||||
| `registerScopedFilesystemTool(basePath, excludePatterns?)` | Register filesystem tool with path restriction |
|
||||
| `setGuardianPolicy(policy)` | Update Guardian policy at runtime |
|
||||
| `getHistory()` | Get conversation history |
|
||||
|
||||
Reference in New Issue
Block a user