@@ -50,7 +50,8 @@ const result = await generateObject({
5050
5151### Agent with Tools
5252A tool agent will recurse until it has what it needs to export a final answer.
53- By default, the format of the final answer is { answer: string }
53+ By default, the format of the final answer is ` { answer: string } ` .
54+
5455``` ts
5556import { createAgent , createTool } from ' @rubriclab/agents'
5657import { z } from ' zod'
@@ -70,6 +71,7 @@ const { executeAgent, eventTypes, __ToolEvent, __ResponseEvent } = createAgent({
7071 tools: { getWeather: weatherTool }
7172})
7273```
74+
7375``` ts
7476// Execute the agent
7577
@@ -102,6 +104,7 @@ export async function sendMessage({ userId, message }: { userId: string; message
102104### Response Format
103105You can override the default response format and agents that return complex types.
104106Supplying an agent BOTH tools and response format will cause the agent to recurse using tools, and when ready, the response in the right format.
107+
105108``` ts
106109const responseFormat = createResponseFormat ({
107110 name: ' research_results' ,
@@ -111,6 +114,7 @@ const responseFormat = createResponseFormat({
111114 })
112115})
113116```
117+
114118``` ts
115119const { executeAgent } = createAgent ({
116120 systemPrompt ,
@@ -122,7 +126,8 @@ const { executeAgent } = createAgent({
122126## Usage with other packages
123127
124128### Usage with [ @rubriclab/events ] ( https://github.com/RubricLab/events )
125- The ` createAgent(...) ` function returns ` eventTypes ` which is a record of zod types.
129+ The ` createAgent(...) ` function returns ` eventTypes ` which is a record of Zod types.
130+
126131``` ts
127132const { executeAgent, eventTypes } = createAgent ({
128133 systemPrompt ,
@@ -144,6 +149,7 @@ export const eventTypes = createEventTypes({
144149```
145150
146151You can then publish them safely:
152+
147153``` ts
148154import env from ' ~/env'
149155import { executeResearchAgent } from ' ./agent'
@@ -174,6 +180,7 @@ await executeResearchAgent({
174180```
175181
176182And consume them on the client with end to end safety:
183+
177184``` ts
178185useEvents ({
179186 id: userId ,
0 commit comments