Skip to content

Commit 9fe9560

Browse files
authored
Remove TaskHandlerResult and use TaskResult directly. (#93)
* remove TaskHandlerResult * changelog * update notebooks
1 parent d82f42e commit 9fe9560

File tree

7 files changed

+174
-88
lines changed

7 files changed

+174
-88
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
1414

1515
### Changed
1616

17+
- Remove TaskHandlerResult and use TaskResult directly (#93)
1718
- Improve `NextStepDecision` to allow for only one next_step or task_result (#88)
1819

1920
## [0.0.6] - 2025-07-27

docs/notebooks/first_llm_agent.ipynb

Lines changed: 150 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@
219219
{
220220
"data": {
221221
"text/plain": [
222-
"Task(id_='25aa12c3-ae1a-415c-a186-102b4412c268', instruction='Add one to fifty-five point three. Use an appropriate tool!')"
222+
"Task(id_='38bb636c-3dd2-4916-a45f-f3fb2ada8bec', instruction='Add one to fifty-five point three. Use an appropriate tool!')"
223223
]
224224
},
225225
"execution_count": 13,
@@ -249,7 +249,7 @@
249249
"DEBUG (llm_agents_fs.TaskHandler) : 💬 ASSISTANT: \n",
250250
"INFO (llm_agents_fs.TaskHandler) : 🛠️ Executing Tool Call: add_one\n",
251251
"INFO (llm_agents_fs.TaskHandler) : ✅ Successful Tool Call: 56.3\n",
252-
"INFO (llm_agents_fs.TaskHandler) : ✅ Step Result: The result of adding one to 55.3 is 56.3.\n",
252+
"INFO (llm_agents_fs.TaskHandler) : ✅ Step Result: The result of adding one to fifty-five point three is fifty-six point three.\n",
253253
"DEBUG (llm_agents_fs.TaskHandler) : 🧵 Rollout: assistant: The current instruction is 'Add one to fifty-five point three. Use an appropriate tool!'\n",
254254
"assistant: I need to make a tool call(s) to `add_one`.\n",
255255
"tool: {\n",
@@ -262,7 +262,7 @@
262262
" \"content\": \"56.3\",\n",
263263
" \"error\": false\n",
264264
"}\n",
265-
"assistant: The result of adding one to 55.3 is 56.3.\n",
265+
"assistant: The result of adding one to fifty-five point three is fifty-six point three.\n",
266266
"DEBUG (llm_agents_fs.TaskHandler) : ---NEXT STEP PROMPT: You are overseeing an assistant's\n",
267267
"progress in accomplishing a user instruction. Provided below is the assistant's\n",
268268
"current response to the original task instruction. Also provided, is an\n",
@@ -277,7 +277,7 @@
277277
"</user-instruction>\n",
278278
"\n",
279279
"<current-response>\n",
280-
"The result of adding one to 55.3 is 56.3.\n",
280+
"The result of adding one to fifty-five point three is fifty-six point three.\n",
281281
"</current-response>\n",
282282
"\n",
283283
"<thinking-process>\n",
@@ -293,17 +293,140 @@
293293
" \"content\": \"56.3\",\n",
294294
" \"error\": false\n",
295295
"}\n",
296-
"assistant: The result of adding one to 55.3 is 56.3.\n",
296+
"assistant: The result of adding one to fifty-five point three is fifty-six point three.\n",
297297
"</thinking-process>\n",
298298
"\n",
299-
"DEBUG (llm_agents_fs.TaskHandler) : ---NEXT STEP: {\"task_step\":{\"id_\":\"915cca85-0b6b-477d-921e-0dce7b8b3533\",\"task_id\":\"add-one-to-55-point-three\",\"instruction\":\"Add one to fifty-five point three using the tool add_one.\"},\"task_result\":{\"task_id\":\"add-one-to-55-point-three\",\"content\":\"The result of adding one to 55.3 is 56.3.\"}}\n",
299+
"DEBUG (llm_agents_fs.TaskHandler) : ---NEXT STEP: {\"kind\":\"next_step\",\"content\":\"I need to make a tool call to `add_one` with the number '55.3' as an argument.\"}\n",
300+
"INFO (llm_agents_fs.TaskHandler) : 🧠 New Step: I need to make a tool call to `add_one` with the number '55.3' as an argument.\n",
301+
"INFO (llm_agents_fs.TaskHandler) : ⚙️ Processing Step: I need to make a tool call to `add_one` with the number '55.3' as an argument.\n",
302+
"DEBUG (llm_agents_fs.TaskHandler) : 🧵 Rollout: assistant: The current instruction is 'Add one to fifty-five point three. Use an appropriate tool!'\n",
303+
"assistant: I need to make a tool call(s) to `add_one`.\n",
304+
"tool: {\n",
305+
" \"tool_call\": {\n",
306+
" \"tool_name\": \"add_one\",\n",
307+
" \"arguments\": {\n",
308+
" \"x\": \"55.3\"\n",
309+
" }\n",
310+
" },\n",
311+
" \"content\": \"56.3\",\n",
312+
" \"error\": false\n",
313+
"}\n",
314+
"assistant: The result of adding one to fifty-five point three is fifty-six point three.\n",
315+
"DEBUG (llm_agents_fs.TaskHandler) : 💬 SYSTEM: You are a helpful assistant.\n",
316+
"\n",
317+
"Here is some past dialogue and context, where another assistant was working\n",
318+
"towards completing the task.\n",
319+
"\n",
320+
"<history>\n",
321+
"assistant: The current instruction is 'Add one to fifty-five point three. Use an appropriate tool!'\n",
322+
"assistant: I need to make a tool call(s) to `add_one`.\n",
323+
"tool: {\n",
324+
" \"tool_call\": {\n",
325+
" \"tool_name\": \"add_one\",\n",
326+
" \"arguments\": {\n",
327+
" \"x\": \"55.3\"\n",
328+
" }\n",
329+
" },\n",
330+
" \"content\": \"56.3\",\n",
331+
" \"error\": false\n",
332+
"}\n",
333+
"assistant: The result of adding one to fifty-five point three is fifty-six point three.\n",
334+
"</history>\n",
335+
"\n",
336+
"DEBUG (llm_agents_fs.TaskHandler) : 💬 USER INPUT: I need to make a tool call to `add_one` with the number '55.3' as an argument.\n",
337+
"DEBUG (llm_agents_fs.TaskHandler) : 💬 ASSISTANT: \n",
338+
"INFO (llm_agents_fs.TaskHandler) : 🛠️ Executing Tool Call: add_one\n",
339+
"INFO (llm_agents_fs.TaskHandler) : ✅ Successful Tool Call: 56.3\n",
340+
"INFO (llm_agents_fs.TaskHandler) : ✅ Step Result: The result of adding one to fifty-five point three is fifty-six point three.\n",
341+
"DEBUG (llm_agents_fs.TaskHandler) : 🧵 Rollout: assistant: The current instruction is 'Add one to fifty-five point three. Use an appropriate tool!'\n",
342+
"assistant: I need to make a tool call(s) to `add_one`.\n",
343+
"tool: {\n",
344+
" \"tool_call\": {\n",
345+
" \"tool_name\": \"add_one\",\n",
346+
" \"arguments\": {\n",
347+
" \"x\": \"55.3\"\n",
348+
" }\n",
349+
" },\n",
350+
" \"content\": \"56.3\",\n",
351+
" \"error\": false\n",
352+
"}\n",
353+
"assistant: The result of adding one to fifty-five point three is fifty-six point three.assistant: The current instruction is 'I need to make a tool call to `add_one` with the number '55.3' as an argument.'\n",
354+
"assistant: I need to make a tool call(s) to `add_one`.\n",
355+
"tool: {\n",
356+
" \"tool_call\": {\n",
357+
" \"tool_name\": \"add_one\",\n",
358+
" \"arguments\": {\n",
359+
" \"x\": \"55.3\"\n",
360+
" }\n",
361+
" },\n",
362+
" \"content\": \"56.3\",\n",
363+
" \"error\": false\n",
364+
"}\n",
365+
"assistant: The result of adding one to fifty-five point three is fifty-six point three.\n",
366+
"DEBUG (llm_agents_fs.TaskHandler) : ---NEXT STEP PROMPT: You are overseeing an assistant's\n",
367+
"progress in accomplishing a user instruction. Provided below is the assistant's\n",
368+
"current response to the original task instruction. Also provided, is an\n",
369+
"internal 'thinking' process of the assistant that the user has not seen.\n",
370+
"\n",
371+
"Determine if the current the response is sufficient to answer the original task\n",
372+
"instruction. In the case that it is not, provide a new instruction to the\n",
373+
"assistant in order to help them improve upon their current response.\n",
374+
"\n",
375+
"<user-instruction>\n",
376+
"Add one to fifty-five point three. Use an appropriate tool!\n",
377+
"</user-instruction>\n",
378+
"\n",
379+
"<current-response>\n",
380+
"The result of adding one to fifty-five point three is fifty-six point three.\n",
381+
"</current-response>\n",
382+
"\n",
383+
"<thinking-process>\n",
384+
"assistant: The current instruction is 'Add one to fifty-five point three. Use an appropriate tool!'\n",
385+
"assistant: I need to make a tool call(s) to `add_one`.\n",
386+
"tool: {\n",
387+
" \"tool_call\": {\n",
388+
" \"tool_name\": \"add_one\",\n",
389+
" \"arguments\": {\n",
390+
" \"x\": \"55.3\"\n",
391+
" }\n",
392+
" },\n",
393+
" \"content\": \"56.3\",\n",
394+
" \"error\": false\n",
395+
"}\n",
396+
"assistant: The result of adding one to fifty-five point three is fifty-six point three.assistant: The current instruction is 'I need to make a tool call to `add_one` with the number '55.3' as an argument.'\n",
397+
"assistant: I need to make a tool call(s) to `add_one`.\n",
398+
"tool: {\n",
399+
" \"tool_call\": {\n",
400+
" \"tool_name\": \"add_one\",\n",
401+
" \"arguments\": {\n",
402+
" \"x\": \"55.3\"\n",
403+
" }\n",
404+
" },\n",
405+
" \"content\": \"56.3\",\n",
406+
" \"error\": false\n",
407+
"}\n",
408+
"assistant: The result of adding one to fifty-five point three is fifty-six point three.\n",
409+
"</thinking-process>\n",
410+
"\n",
411+
"DEBUG (llm_agents_fs.TaskHandler) : ---NEXT STEP: {\"kind\":\"final_result\",\"content\":\"The result of adding one to fifty-five point three is fifty-six point three.\"}\n",
300412
"INFO (llm_agents_fs.TaskHandler) : No new step required.\n",
301-
"INFO (llm_agents_fs.LLMAgent) : 🏁 Task completed: The result of adding one to 55.3 is 56.3.\n"
413+
"INFO (llm_agents_fs.LLMAgent) : 🏁 Task completed: The result of adding one to fifty-five point three is fifty-six point three.\n"
302414
]
415+
},
416+
{
417+
"data": {
418+
"text/plain": [
419+
"TaskResult(task_id='38bb636c-3dd2-4916-a45f-f3fb2ada8bec', content='The result of adding one to fifty-five point three is fifty-six point three.')"
420+
]
421+
},
422+
"execution_count": 14,
423+
"metadata": {},
424+
"output_type": "execute_result"
303425
}
304426
],
305427
"source": [
306-
"result = await agent.run(task)"
428+
"handler = agent.run(task)\n",
429+
"await handler"
307430
]
308431
},
309432
{
@@ -315,7 +438,7 @@
315438
{
316439
"data": {
317440
"text/plain": [
318-
"TaskResult(task_id='25aa12c3-ae1a-415c-a186-102b4412c268', content='The result of adding one to 55.3 is 56.3.')"
441+
"TaskResult(task_id='38bb636c-3dd2-4916-a45f-f3fb2ada8bec', content='The result of adding one to fifty-five point three is fifty-six point three.')"
319442
]
320443
},
321444
"execution_count": 15,
@@ -324,7 +447,8 @@
324447
}
325448
],
326449
"source": [
327-
"result.task_result"
450+
"result = handler.result()\n",
451+
"result"
328452
]
329453
},
330454
{
@@ -337,12 +461,12 @@
337461
"name": "stdout",
338462
"output_type": "stream",
339463
"text": [
340-
"The result of adding one to 55.3 is 56.3.\n"
464+
"The result of adding one to fifty-five point three is fifty-six point three.\n"
341465
]
342466
}
343467
],
344468
"source": [
345-
"print(result.task_result)"
469+
"print(result)"
346470
]
347471
},
348472
{
@@ -367,12 +491,24 @@
367491
" \"content\": \"56.3\",\n",
368492
" \"error\": false\n",
369493
"}\n",
370-
"assistant: The result of adding one to 55.3 is 56.3.\n"
494+
"assistant: The result of adding one to fifty-five point three is fifty-six point three.assistant: The current instruction is 'I need to make a tool call to `add_one` with the number '55.3' as an argument.'\n",
495+
"assistant: I need to make a tool call(s) to `add_one`.\n",
496+
"tool: {\n",
497+
" \"tool_call\": {\n",
498+
" \"tool_name\": \"add_one\",\n",
499+
" \"arguments\": {\n",
500+
" \"x\": \"55.3\"\n",
501+
" }\n",
502+
" },\n",
503+
" \"content\": \"56.3\",\n",
504+
" \"error\": false\n",
505+
"}\n",
506+
"assistant: The result of adding one to fifty-five point three is fifty-six point three.\n"
371507
]
372508
}
373509
],
374510
"source": [
375-
"print(result.rollout)"
511+
"print(handler.rollout)"
376512
]
377513
}
378514
],

0 commit comments

Comments
 (0)