Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: tool call results are not sent back to model, giving json results back to user instead of human readable text #289

Open
carlos-verdes opened this issue Feb 10, 2025 · 0 comments · May be fixed by #290
Labels

Comments

@carlos-verdes
Copy link
Contributor

  • [ X] I have looked for existing issues (including closed) about this

Bug Report

Tool results should be passed back to the model to generate a human readable answer.
Currently the tool result is sent back to the user.

Reproduction

You can simply run any example agent with a tool which response is a structured model.

If you run an agent with the below SearchTool you will get a conversation like this:

Prompt: Can you please let me know title and url of rig platform?
Response: {"title":"Rig Documentation","url":"https://docs.rig.ai"}

SearchTool implementation:

#[derive(Deserialize, Serialize)]
struct SearchArgs {
    pub query_string: String,
}

#[derive(Deserialize, Serialize)]
struct SearchResult {
    pub title: String,
    pub url: String,
}

#[derive(Debug, thiserror::Error)]
#[error("Search error")]
struct SearchError;

#[derive(Deserialize, Serialize)]
struct SearchTool;

impl Tool for SearchTool {
    const NAME: &'static str = "search";

    type Error = SearchError;
    type Args = SearchArgs;
    type Output = SearchResult;

    async fn definition(&self, _prompt: String) -> ToolDefinition {
        serde_json::from_value(json!({
            "name": "search",
            "description": "Search for a website, it will return the title and URL",
            "parameters": {
                "type": "object",
                "properties": {
                    "query_string": {
                        "type": "string",
                        "description": "The query string to search for"
                    },
                }
            }
        }))
        .expect("Tool Definition")
    }

    async fn call(&self, args: Self::Args) -> Result<Self::Output, Self::Error> {
        println!("[tool-call] Searching for: '{}'", args.query_string);

        if args.query_string.to_lowercase().contains("rig") {
            Ok(SearchResult {
                title: "Rig Documentation".to_string(),
                url: "https://docs.rig.ai".to_string(),
            })
        } else {
            Err(SearchError)
        }
    }
}

Expected behavior

The expectation is a human readable answer sent back to the user.

Example:

Prompt: Can you please let me know title and url of rig platform?
Response: The title of the Rig platform is "Rig Documentation" and the URL is [https://docs.rig.ai](https://docs.rig.ai).

Additional context

OpenAI function calling

Image
@carlos-verdes carlos-verdes linked a pull request Feb 10, 2025 that will close this issue
@0xMochan 0xMochan changed the title bug: tool call results are not sent back to model, giving json results back to user instead of human readable text feat: tool call results are not sent back to model, giving json results back to user instead of human readable text Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants