@agentfield/sdk 0.1.46 → 0.1.47-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +44 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -39,6 +39,50 @@ const limiter = new StatelessRateLimiter({ maxRetries: 3, baseDelay: 0.5 });
39
39
  const result = await limiter.executeWithRetry(() => makeAiCall());
40
40
  ```
41
41
 
42
+ ## AI Tool Calling
43
+
44
+ Let LLMs automatically discover and invoke agent capabilities:
45
+
46
+ ```ts
47
+ import { Agent } from '@agentfield/sdk';
48
+ import type { ToolCallConfig } from '@agentfield/sdk';
49
+
50
+ const agent = new Agent({
51
+ nodeId: 'orchestrator',
52
+ agentFieldUrl: 'http://localhost:8080',
53
+ aiConfig: { provider: 'openrouter', model: 'openai/gpt-4o-mini' },
54
+ });
55
+
56
+ agent.reasoner('ask', async (ctx) => {
57
+ // Auto-discover all tools and let the LLM use them
58
+ const { text, trace } = await ctx.aiWithTools(ctx.input.question, {
59
+ tools: 'discover',
60
+ system: 'You are a helpful assistant.',
61
+ });
62
+
63
+ console.log(`Tool calls: ${trace.totalToolCalls}, Turns: ${trace.totalTurns}`);
64
+ return { answer: text };
65
+ });
66
+
67
+ // Filter by tags, set guardrails
68
+ agent.reasoner('weather', async (ctx) => {
69
+ const { text } = await ctx.aiWithTools(ctx.input.cities, {
70
+ tools: { tags: ['weather'] } satisfies ToolCallConfig,
71
+ maxTurns: 3,
72
+ maxToolCalls: 5,
73
+ });
74
+ return { report: text };
75
+ });
76
+ ```
77
+
78
+ **Key features:**
79
+ - `tools: 'discover'` — Auto-discover all capabilities from the control plane
80
+ - `ToolCallConfig` — Filter by tags, agent IDs; lazy/eager schema hydration
81
+ - **Guardrails** — `maxTurns` and `maxToolCalls` prevent runaway loops
82
+ - **Observability** — `trace` tracks every tool call with latency
83
+
84
+ See `examples/ts_agent_nodes/tool_calling/` for a complete orchestrator + worker example.
85
+
42
86
  ## Execution Notes
43
87
 
44
88
  Log execution progress with `ctx.note(message: string, tags?: string[])` for fire-and-forget debugging in the AgentField UI.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentfield/sdk",
3
- "version": "0.1.46",
3
+ "version": "0.1.47-rc.1",
4
4
  "description": "AgentField TypeScript SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",