fix: unstuck agent after tool calls, display completed streams

This commit is contained in:
Shivering Ocelot committed 2026-10-09 13:36:06 -05:00
1 parent c9a76e7fb3
commit 161dfd507f
4 files changed
+11 -3

No files matched your search

+1
View File
@@ -66,6 +66,7 @@ class Agent:
agent_run.close()
raise NotImplementedError("Subclasses must implement run()")
# Deprecate this. This is just run with extra baggage.
async def prompt(self, instruction, input=None, **kwargs):
run = AgentRun.create(
self.app,
+6 -2
View File
@@ -40,6 +40,9 @@ async def chat_completion_loop(app, run, messages, model_id=None, tools=None):
run.emit_event('inference', msg)
# Broken generator with no output
else: break
for tc in tool_calls:
tool = next((t for t in tools if t.name == tc.tool_name), None)
if tool is None:
@@ -50,8 +53,9 @@ async def chat_completion_loop(app, run, messages, model_id=None, tools=None):
else:
tc.tool = tool
# By default, end if there's no calls
else: break
# If not calling must output something useful
else:
if turn_response: break
run.close()
+1 -1
View File
@@ -149,7 +149,7 @@ class Tool:
@classmethod
def tool_name(cls):
return ''.join(['_'+c.lower() if c.isupper() else c for c in cls.__name__]).lstrip('_')
return ''.join(['-'+c.lower() if c.isupper() else c for c in cls.__name__]).lstrip('_')
def _generate_spec(self):
+3
View File
@@ -20,7 +20,10 @@ def encode_value(value):
json['result'] = encode_value(value.result),
return json
elif isinstance(value, Stream):
if value.open:
return {'streamId': value.id}
else:
return value.content
else:
return value