V0.8.0 #49

Closed
ton wants to merge 121 commits from v0.8.0 into main
2 changed files with 6 additions and 6 deletions
Showing only changes of commit 471da0c5ec - Show all commits
+3 -3
View File
@@ -156,13 +156,13 @@ function yiemAgent(
# MCP protocol: tools/list — returns tool definitions (JSON-RPC 2.0)
# check input and output format from MCP server doc
function (mcp::mcpServer)(method::String, sessionId::String)::AbstractDict{String, <:Any}
function (mcp::mcpServer)(method::String, sessionId::String; eventSink=nothing)::AbstractDict{String, <:Any}
error("please implement MCP server tools/list interface")
end
# MCP protocol: tools/call — executes a tool (JSON-RPC 2.0)
function (mcp::mcpServer)(method::String, toolName::String, arguments::Dict{String, Any},
sessionId::String)::AbstractDict{String, <:Any}
sessionId::String; eventSink=nothing)::AbstractDict{String, <:Any}
error("please implement MCP server interface")
end
""")
@@ -453,7 +453,7 @@ function _processMessage(
""" response example
response = JSON.Object{String, Any}("finish_reason" => "tool_calls", "index" => 0, "message" => JSON.Object{String, Any}("role" => "assistant", "content" => "", "reasoning_content" => "Here's a thinking process:\n\n1. **Identify User Request**: The user is asking for the weather in Bangkok.\n2. **Locate Relevant Tool**: I have a `getWeather` function available.\n3. **Check Function Parameters**:\n - `city` (required): City and country, e.g., 'San Francisco, CA' or 'Tokyo, Japan'\n - `units` (optional, default \"celsius\"): Temperature scale (\"celsius\" or \"fahrenheit\")\n4. **Prepare Parameters**:\n - `city`: \"Bangkok, Thailand\" (adding country for clarity, though just \"Bangkok\" might work, following the example format is safer)\n - `units`: Not specified, so I'll use the default (\"celsius\")\n5. **Execute Tool Call**: Call `getWeather` with `city: \"Bangkok, Thailand\"`\n6. **Anticipate Response**: The function will return current weather and forecast data for Bangkok. I'll then format it nicely for the user.\n - *Self-Correction/Verification during thought*: The prompt says \"city: City and country, e.g., 'San Francisco, CA' or 'Tokyo, Japan'\". I'll use \"Bangkok, Thailand\". The `units` parameter is optional, so I'll omit it to use the default.\n - Proceed with tool call.✅\n", "tool_calls" => Any[JSON.Object{String, Any}("type" => "function", "function" => JSON.Object{String, Any}("name" => "getWeather", "arguments" => "{\"city\":\"Bangkok, Thailand\"}"), "id" => "6fOilR5QPcdppbAAHluhkRyUDu3oWMAL")]))
"""
response = llmCall(formattedMessages)
response = llmCall(formattedMessages, eventSink=eventSink)
# eventSink("LLM response " * string(response); publish=false, log=true)
eventSink("_processMessage 11 _state.messages length $(length(agentMsgHistory))"; publish=false, log=true)
+3 -3
View File
@@ -68,7 +68,7 @@ function _wrap_mcp_tool(mcpserver, tool_def::AbstractDict{String, Any}; eventSin
signal::Union{Nothing,abortSignal},
eventSink) -> begin
try
response = mcpserver("tools/call", name, args, sessionId)
response = mcpserver("tools/call", name, args, sessionId; eventSink=eventSink)
# Parse JSON-RPC 2.0 response envelope
if haskey(response, "error")
@@ -122,7 +122,7 @@ function register_mcp_tools(tools::OrderedDict{String, agentTool}, mcpserver; ev
new_count = 0
try
eventSink("register_mcp_tools 1")
response = mcpserver("tools/list", sessionId)
response = mcpserver("tools/list", sessionId; eventSink=eventSink)
eventSink("register_mcp_tools 2")
# Parse JSON-RPC 2.0 response envelope
if haskey(response, "error")
@@ -151,7 +151,7 @@ function register_mcp_tools(tools::OrderedDict{String, agentTool}, mcpserver; ev
# Paginate: fetch remaining tools if nextCursor is present
while cursor !== nothing && cursor !== ""
response = sessionId !== nothing ? mcpserver("tools/list", sessionId) : mcpserver("tools/list")
response = sessionId !== nothing ? mcpserver("tools/list", sessionId; eventSink=eventSink) : mcpserver("tools/list"; eventSink=eventSink)
if haskey(response, "result")
response = response["result"]
end