Skip to content

Commit c7743c1

Browse files
committed
update
1 parent e2940d3 commit c7743c1

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

agent-todo/readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ You can run agents from the UI by clicking the "Run" button.
3636

3737
You can run agents from the API by using the generated endpoint:
3838

39-
`POST http://localhost:6233/api/agents/agentChatTool`
39+
`POST http://localhost:6233/api/agents/agentTodo`
4040

4141
### from any client
4242

@@ -46,7 +46,7 @@ You can run agents with any client connected to Restack, for example:
4646
npm run schedule
4747
```
4848

49-
executes `scheduleAgent.ts` which will connect to Restack and execute the `agentChatTool` agent.
49+
executes `scheduleAgent.ts` which will connect to Restack and execute the `agentTodo` agent.
5050

5151
## Send events to the Agent
5252

@@ -64,14 +64,14 @@ And see the events in the run:
6464

6565
You can send events to the agent by using the following endpoint:
6666

67-
`PUT http://localhost:6233/api/agents/agentChatTool/:agentId/:runId`
67+
`PUT http://localhost:6233/api/agents/agentTodo/:agentId/:runId`
6868

6969
with the payload:
7070

7171
```json
7272
{
7373
"eventName": "message",
74-
"eventInput": { "content": "Sales on boots?" }
74+
"eventInput": { "content": "Create todo to send email to CEO" }
7575
}
7676
```
7777

agent-todo/src/agents/agent.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,34 +33,34 @@ export async function agentTodo(): Promise<agentTodoOutput> {
3333
tools,
3434
});
3535

36-
messages.push({ role: "assistant", content: result.content });
36+
messages.push(result);
3737

3838
if (result.tool_calls) {
39+
log.info("result.tool_calls", { result });
3940
for (const toolCall of result.tool_calls) {
4041
switch (toolCall.function.name) {
4142
case "createTodo":
43+
log.info("createTodo", { toolCall });
4244
const toolResult = await step<typeof functions>({}).createTodo(
4345
JSON.parse(toolCall.function.arguments)
4446
);
4547

4648
messages.push({
4749
role: "tool",
4850
tool_call_id: toolCall.id,
49-
content: JSON.stringify(toolResult),
51+
content: toolResult,
5052
});
5153

5254
const toolChatResult = await step<typeof functions>({}).llmChat({
5355
messages,
5456
tools,
5557
});
5658

57-
messages.push({
58-
role: "assistant",
59-
content: toolChatResult.content,
60-
});
59+
messages.push(toolChatResult);
6160

6261
break;
6362
case "executeTodoWorkflow":
63+
log.info("executeTodoWorkflow", { toolCall });
6464
const workflowId = `executeTodoWorkflow-${new Date().getTime()}`;
6565
const workflowResult = await childExecute({
6666
child: executeTodoWorkflow,
@@ -81,10 +81,7 @@ export async function agentTodo(): Promise<agentTodoOutput> {
8181
}
8282
);
8383

84-
messages.push({
85-
role: "assistant",
86-
content: toolWorkflowResult.content,
87-
});
84+
messages.push(toolWorkflowResult);
8885

8986
break;
9087
default:

0 commit comments

Comments
 (0)