Skip to content

stop_tool_calls_and_respond! breaks tool calls? #37

@joshforbes

Description

@joshforbes

I must be doing something wrong here, I feel like I'm missing something. Anytime I add the stop_tool_calls_and_respond! to a function, the LLM responds like it can't see any tools at all.

Image

I, [2025-07-01T21:19:25.118808 #63129]  INFO -- : request: POST https://openrouter.ai/api/v1/chat/completions
I, [2025-07-01T21:19:25.118860 #63129]  INFO -- : request: Authorization: "Bearer[REDACTED]
Content-Type: "application/json"
X-Title: "OpenRouter Ruby Client"
HTTP-Referer: "https://github.com/OlympiaAI/open_router"
I, [2025-07-01T21:19:25.118883 #63129]  INFO -- : request: {"messages":[{"role":"user","content":"Use the available tool"}],"model":"anthropic/claude-sonnet-4","max_tokens":1000,"temperature":0.0,"tools":[{"type":"function","function":{"name":"test","parameters":{"type":"object","properties":{}},"description":"Call this tool"}}]}
I, [2025-07-01T21:19:27.058307 #63129]  INFO -- : response: Status 200
I, [2025-07-01T21:19:27.058375 #63129]  INFO -- : response: date: "Tue, 01 Jul 2025 21:19:26 GMT"
content-type: "application/json"
transfer-encoding: "chunked"
connection: "keep-alive"
access-control-allow-origin: "*"
vary: "Accept-Encoding"
server: "cloudflare"
cf-ray: "9588f1073937df73-IAD"
I, [2025-07-01T21:19:27.058411 #63129]  INFO -- : response: 
         
{"id":"gen-1751404765-sW7r6Kz2503jNJWKfCxn","provider":"Google","model":"anthropic/claude-sonnet-4","object":"chat.completion","created":1751404765,"choices":[{"logprobs":null,"finish_reason":"tool_calls","native_finish_reason":"tool_calls","index":0,"message":{"role":"assistant","content":"I'll use the available tool for you.","refusal":null,"reasoning":null,"tool_calls":[{"id":"toolu_vrtx_01PjBBiSNE7ytfzQVYkWEVpR","index":0,"type":"function","function":{"name":"test","arguments":""}}]}}],"usage":{"prompt_tokens":359,"completion_tokens":44,"total_tokens":403}}
I, [2025-07-01T21:19:27.059205 #63129]  INFO -- : request: POST https://openrouter.ai/api/v1/chat/completions
I, [2025-07-01T21:19:27.059249 #63129]  INFO -- : request: Authorization: "Bearer[REDACTED]
Content-Type: "application/json"
X-Title: "OpenRouter Ruby Client"
HTTP-Referer: "https://github.com/OlympiaAI/open_router"
I, [2025-07-01T21:19:27.059273 #63129]  INFO -- : request: {"messages":[{"role":"user","content":"Use the available tool"}],"model":"anthropic/claude-sonnet-4","max_tokens":1000,"temperature":0.0}
I, [2025-07-01T21:19:29.619985 #63129]  INFO -- : response: Status 200
I, [2025-07-01T21:19:29.620248 #63129]  INFO -- : response: date: "Tue, 01 Jul 2025 21:19:27 GMT"
content-type: "application/json"
transfer-encoding: "chunked"
connection: "keep-alive"
access-control-allow-origin: "*"
vary: "Accept-Encoding"
server: "cloudflare"
cf-ray: "9588f1135f565774-IAD"
I, [2025-07-01T21:19:29.620462 #63129]  INFO -- : response: 
         
{"id":"gen-1751404767-K5LJ3ze8JEh9MPwzwbzV","provider":"Google","model":"anthropic/claude-sonnet-4","object":"chat.completion","created":1751404767,"choices":[{"logprobs":null,"finish_reason":"stop","native_finish_reason":"stop","index":0,"message":{"role":"assistant","content":"I don't see any tools available in our current conversation. Could you please clarify what tool you'd like me to use? \n\nIf you're expecting me to have access to a specific tool (like a calculator, web search, code interpreter, etc.), you may need to:\n\n1. Specify which tool you want me to use\n2. Provide the tool or enable it in your interface\n3. Give me more context about what task you'd like me to accomplish with a tool\n\nWhat would you like me to help you with?","refusal":null,"reasoning":null}}],"usage":{"prompt_tokens":11,"completion_tokens":116,"total_tokens":127}}
"I don't see any tools available in our current conversation. Could you please clarify what tool you'd like me to use? \n" +
"\n" +
"If you're expecting me to have access to a specific tool (like a calculator, web search, code interpreter, etc.), you may need to:\n" +
"\n" +
"1. Specify which tool you want me to use\n" +
"2. Provide the tool or enable it in your interface\n" +
"3. Give me more context about what task you'd like me to accomplish with a tool\n" +
"\n" +
"What would you like me to help you with?"

But if I remove that one line:

Image

I, [2025-07-01T21:21:04.030335 #64307]  INFO -- : request: POST https://openrouter.ai/api/v1/chat/completions
I, [2025-07-01T21:21:04.030390 #64307]  INFO -- : request: Authorization: "Bearer[REDACTED]
Content-Type: "application/json"
X-Title: "OpenRouter Ruby Client"
HTTP-Referer: "https://github.com/OlympiaAI/open_router"
I, [2025-07-01T21:21:04.030414 #64307]  INFO -- : request: {"messages":[{"role":"user","content":"Use the available tool"}],"model":"anthropic/claude-sonnet-4","max_tokens":1000,"temperature":0.0,"tools":[{"type":"function","function":{"name":"test","parameters":{"type":"object","properties":{}},"description":"Call this tool"}}]}
I, [2025-07-01T21:21:05.965741 #64307]  INFO -- : response: Status 200
I, [2025-07-01T21:21:05.965827 #64307]  INFO -- : response: date: "Tue, 01 Jul 2025 21:21:05 GMT"
content-type: "application/json"
transfer-encoding: "chunked"
connection: "keep-alive"
access-control-allow-origin: "*"
vary: "Accept-Encoding"
server: "cloudflare"
cf-ray: "9588f37168a28bd6-IAD"
I, [2025-07-01T21:21:05.965858 #64307]  INFO -- : response: 
         
{"id":"gen-1751404864-d5CHXGNIcXeCd58bea5y","provider":"Google","model":"anthropic/claude-sonnet-4","object":"chat.completion","created":1751404864,"choices":[{"logprobs":null,"finish_reason":"tool_calls","native_finish_reason":"tool_calls","index":0,"message":{"role":"assistant","content":"I'll use the available tool for you.","refusal":null,"reasoning":null,"tool_calls":[{"id":"toolu_vrtx_01A9tuQudwLYUaYhQFXeuvtF","index":0,"type":"function","function":{"name":"test","arguments":""}}]}}],"usage":{"prompt_tokens":359,"completion_tokens":44,"total_tokens":403}}
I, [2025-07-01T21:21:05.966519 #64307]  INFO -- : request: POST https://openrouter.ai/api/v1/chat/completions
I, [2025-07-01T21:21:05.966545 #64307]  INFO -- : request: Authorization: "Bearer[REDACTED]
Content-Type: "application/json"
X-Title: "OpenRouter Ruby Client"
HTTP-Referer: "https://github.com/OlympiaAI/open_router"
I, [2025-07-01T21:21:05.966568 #64307]  INFO -- : request: {"messages":[{"role":"user","content":"Use the available tool"},{"role":"assistant","content":null,"tool_calls":[{"id":"c9f5986c-9d7e-4159-8743","type":"function","function":{"name":"test","arguments":"{}"}}]},{"role":"tool","tool_call_id":"c9f5986c-9d7e-4159-8743","name":"test","content":"Let the user know that the tool was used"}],"model":"anthropic/claude-sonnet-4","max_tokens":1000,"temperature":0.0,"tools":[{"type":"function","function":{"name":"test","parameters":{"type":"object","properties":{}},"description":"Call this tool"}}]}
I, [2025-07-01T21:21:07.869923 #64307]  INFO -- : response: Status 200
I, [2025-07-01T21:21:07.870027 #64307]  INFO -- : response: date: "Tue, 01 Jul 2025 21:21:07 GMT"
content-type: "application/json"
transfer-encoding: "chunked"
connection: "keep-alive"
access-control-allow-origin: "*"
vary: "Accept-Encoding"
server: "cloudflare"
cf-ray: "9588f37d7e87c932-IAD"
I, [2025-07-01T21:21:07.870061 #64307]  INFO -- : response: 
         
{"id":"gen-1751404866-7raGSzOBJFRZdmagdAhS","provider":"Google","model":"anthropic/claude-sonnet-4","object":"chat.completion","created":1751404866,"choices":[{"logprobs":null,"finish_reason":"stop","native_finish_reason":"stop","index":0,"message":{"role":"assistant","content":"I've successfully used the available tool. The tool has been called and executed as requested.","refusal":null,"reasoning":null}}],"usage":{"prompt_tokens":415,"completion_tokens":21,"total_tokens":436}}
"I've successfully used the available tool. The tool has been called and executed as requested."

Sorry... I'm likely just missing some key piece of documentation? I think I was expecting it to not have that final response message. Is the expectation that I should discard the final assistant message?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions