Skip to content

Problem calling ctx.subtask() from GOAP action #1322

@pambrose

Description

@pambrose

A repo with the code having the issue at: https://github.com/pambrose/koog-issue

The issue can be found in src/main/kotlin/goap/ToolCallBaristaDemo.kt.

The Brew coffee action invokes ctx.subtask() near line 103, which is supposed to result in a
tool call to increase the temperature. When run, you can see the tool call being successfully made, but
the subtask fails in AIAgentFunctionalContext.sendToolResult() after appending the default finishTool
results and calling requestLLM().

The resulting error is:

Exception in thread "main" ai.koog.prompt.executor.clients.LLMClientException: Error from client: OpenAILLMClient
Error from client: OpenAILLMClient
Status code: 400
Error body:
{
  "error": {
    "message": "Invalid parameter: messages with role 'tool' must be a response to a preceeding message with 'tool_calls'.",
    "type": "invalid_request_error",
    "param": "messages.[6].role",
    "code": null
  }
}

Metadata

Metadata

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions