Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions ex_app/lib/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@
from ex_app.lib.signature import add_signature, verify_signature
from ex_app.lib.tools import get_tools

# Dummy thread id as we return the whole state
thread = {"configurable": {"thread_id": "thread-1"}}
graph_config = {
# Dummy thread id as we return the whole state
"configurable": {"thread_id": "thread-1"},
# Maximum amount of tool calls per interaction
"recursion_limit": 256
}

key_file_path = persistent_storage() + '/secret_key.txt'

Expand Down Expand Up @@ -206,7 +210,7 @@ async def call_model(

graph = await get_graph(call_model, safe_tools, dangerous_tools, checkpointer)

state_snapshot = graph.get_state(thread)
state_snapshot = graph.get_state(graph_config)

## if the next step is a tool call
if state_snapshot.next == ('dangerous_tools', ):
Expand Down Expand Up @@ -259,7 +263,7 @@ async def report_stream_state(force: bool = False):
last_stream_update = now
last_reported_stream_state = stream_state

async for event in graph.astream(new_input, thread, stream_mode=stream_mode):
async for event in graph.astream(new_input, graph_config, stream_mode=stream_mode):
if isinstance(event, tuple):
mode, payload = event
else:
Expand Down Expand Up @@ -288,7 +292,7 @@ async def report_stream_state(force: bool = False):

await report_stream_state(force=True)

state_snapshot = graph.get_state(thread)
state_snapshot = graph.get_state(graph_config)
actions = ''
if state_snapshot.next == ('dangerous_tools', ):
actions = json.dumps(last_message.tool_calls)
Expand Down
Loading