This commit is contained in:
2026-08-04 12:13:22 +07:00
parent 569f85333f
commit 937d52053f
3 changed files with 46 additions and 45 deletions
+11 -12
View File
@@ -353,18 +353,17 @@ docstring
mutable struct yiemAgent <: agent # High-level agent wrapper
_state::agentState # Current state (prompt, model, messages, tools, etc.)
input_ch::Channel # user sends prompt message to agent.
inputChannel::Channel # user sends prompt message to agent.
# if agent is idle, it process user message right away.
# if agent is running, it process user message after
# the current tool call finished.
followUpQueue::Channel # Messages queued via follow_up() during agent is
# running. After the agent loop process all input_ch
# and the agent isn't using tool call, it processes
# followUp messages
followUpChannel::Channel # Buffers messages the user sends while the agent is busy.
# Processed after all inputChannel messages are handled
# and the agent is idle (not using a tool call).
output_ch::Channel # agent sends response message to user after processing
# all user messages in input_ch and all followUp messages.
outputChannel::Channel # agent sends response message to user after processing
# all user messages in inputChannel and all followUp messages.
_task::Union{Task, Nothing} # Background task running the agent loop
@@ -383,7 +382,7 @@ end
Create a new yiemAgent instance with a background loop task.
Spawns a background `@spawn` task that runs the agent loop, listening
on `input_ch` and `followUpQueue` channels concurrently.
on `inputChannel` and `followUpChannel` channels concurrently.
# Keyword Arguments
- `systemPrompt::String`: System prompt for the agent
@@ -425,16 +424,16 @@ function yiemAgent(
toolExecution=nothing,
)
# Create channels: input (user -> agent), followUp (async queue), output (agent -> user)
input_ch = Channel(16)
inputChannel = Channel(16)
followUp = Channel(32)
output_ch = Channel(16)
outputChannel = Channel(16)
# Create struct with a placeholder task, then spawn and replace it
agent = yiemAgent(
agentState(systemPrompt, model, tools, messages),
input_ch,
inputChannel,
followUp,
output_ch,
outputChannel,
nothing, # placeholder — replaced below
formatMsgForLLM,
preprocessMessages,