Skip to content

Commit 9d3ed3c

Browse files
committed
Graceful exit support.
1 parent f964b56 commit 9d3ed3c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/agents/FluidAgent.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ function work(agent::FluidAgent, session::Session; cache=nothing,
149149
tool_kwargs=Dict(),
150150
thinking::Union{Nothing,Int}=nothing,
151151
MAX_NUMBER_OF_TOOL_CALLS=8,
152+
exit_signal::Ref{Bool}=Ref(false),
152153
)
153154
# Initialize the system message if it hasn't been initialized yet
154155
sys_msg_content = initialize!(agent.sys_msg, agent)
@@ -172,6 +173,7 @@ function work(agent::FluidAgent, session::Session; cache=nothing,
172173
i = 0
173174

174175
while i < MAX_NUMBER_OF_TOOL_CALLS || sum(length(msg.content) for msg in session.messages) < 40000
176+
exit_signal[] && (@info "Exit signal received, stopping gracefully"; break)
175177
i += 1
176178

177179
# Create new ToolTagExtractor for each run

0 commit comments

Comments
 (0)