Skip to content

user_prompt panic in noninteractive mode #1554

@dvdksn

Description

@dvdksn

Describe the bug

if the user_prompt tool is invoked in non-interactive session, cagent panics

Version affected

1.20.0

How To Reproduce

Detailed steps to reproduce the behavior:

# agent.yml
agents:
  root:
    model: anthropic/claude-sonnet-4-5
    instruction: "You're a planning agent that helps the user explore ideas"
    toolsets:
      - type: user_prompt
$ cagent exec agent.yml "it's not working"

--- Agent: root ---
I'd be happy to help you troubleshoot! To better understand what's not working, I need a bit more information.
Calling user_prompt(
  message: "Could you please describe what's not working? For example:\n- What are you trying to do?\n- What's happening instead of what you expected?\n- Are there any error messages?\n- When did this issue start?"
  schema: {
  "properties": {
    "additional_context": {
      "description": "Any other relevant details",
      "type": "string"
    },
    "error_messages": {
      "description": "Any error messages or warnings (if applicable)",
      "type": "string"
    },
    "what_happens": {
      "description": "What's actually happening?",
      "type": "string"
    },
    "what_trying_to_do": {
      "description": "What are you trying to accomplish?",
      "type": "string"
    }
  },
  "required": [
    "what_trying_to_do",
    "what_happens"
  ],
  "type": "object"
}
)
panic: interface conversion: interface {} is nil, not string

goroutine 1 [running]:
github.com/docker/cagent/pkg/cli.Run.func1({0x16afdf5d6?, 0x1400088c140?}, {0x1076ecf98, 0x14000120018})
	github.com/docker/cagent/pkg/cli/runner.go:167 +0xe04
github.com/docker/cagent/pkg/cli.Run({0x107718ba0?, 0x14000483440?}, 0x14000829b48, {{0x1067ce4cd, 0x6}, {0x0, 0x0}, 0x0, 0x0, 0x0}, ...)
	github.com/docker/cagent/pkg/cli/runner.go:199 +0x25c
github.com/docker/cagent/cmd/root.(*runExecFlags).handleExecMode(0x140005e8280, {0x107718ba0, 0x14000483440}, 0x14000829b48, {0x107739da0, 0x140000ec018}, 0x14000c800f0, {0x140004fafc0?, 0x2?, 0x1062e76e4?})
	github.com/docker/cagent/cmd/root/run.go:402 +0x188
github.com/docker/cagent/cmd/root.(*runExecFlags).runOrExec(0x140005e8280, {0x107718ba0, 0x14000483440}, 0x14000829b48, {0x140004fafc0, 0x2, 0x2}, 0x0)
	github.com/docker/cagent/cmd/root/run.go:249 +0x72c
github.com/docker/cagent/cmd/root.(*runExecFlags).runExecCommand(0x140005e8280, 0x140001ffb08, {0x140004fafc0, 0x2, 0x2})
	github.com/docker/cagent/cmd/root/exec.go:43 +0x80
github.com/spf13/cobra.(*Command).execute(0x140001ffb08, {0x140004faf80, 0x2, 0x2})
	github.com/spf13/[email protected]/command.go:1015 +0x7d4
github.com/spf13/cobra.(*Command).ExecuteC(0x140001fef08)
	github.com/spf13/[email protected]/command.go:1148 +0x350
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/[email protected]/command.go:1071
github.com/spf13/cobra.(*Command).ExecuteContext(...)
	github.com/spf13/[email protected]/command.go:1064
github.com/docker/cagent/cmd/root.Execute({0x107718ba0, 0x14000483440}, {0x1076ecf98, 0x14000120018}, {0x1076ecfb8, 0x14000120020}, {0x1076ecfb8, 0x14000120028}, {0x14000136050, 0x3, ...})
	github.com/docker/cagent/cmd/root/root.go:142 +0x260
main.main()
	github.com/docker/cagent/main.go:15 +0xd0

Expectation

It should probably warn and skip the tool if elicitations are not possible.

OS and Terminal type

macOS, kitty

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions