Repository navigation
Description
Summary
cagent panics at session start with interface conversion: interface {} is nil, not string when a script toolset defines a shell tool whose arg omits description.
The crash is in ScriptToolSet.Instructions() (pkg/tools/builtin/shell/script_shell.go:104, v1.74.0):
description := argDef.(map[string]any)["description"].(string)If the arg definition has no description key, the map lookup returns nil and the type assertion panics. The outer argDef.(map[string]any) assertion can also panic if the arg definition is not a mapping (e.g. name: string shorthand or a null value).
Reproduction
agents:
root:
model: anthropic/claude-sonnet-4-6
toolsets:
- type: script
shell:
greet:
cmd: echo hello ${name}
args:
name:
type: string # no description -> panic
required: [name]Start a session with any prompt. The runtime panics before the first model call, while building the system messages:
panic: interface conversion: interface {} is nil, not string
github.com/docker/docker-agent/pkg/tools/builtin/shell.(*ScriptToolSet).Instructions
pkg/tools/builtin/shell/script_shell.go:104
github.com/docker/docker-agent/pkg/tools.GetInstructions
pkg/tools/capabilities.go:72
github.com/docker/docker-agent/pkg/session.buildInvariantSystemMessages
pkg/session/session.go:918
github.com/docker/docker-agent/pkg/session.(*Session).GetMessages
pkg/session/session.go:1053
github.com/docker/docker-agent/pkg/runtime.(*LocalRuntime).runStreamLoop
pkg/runtime/loop.go:261
Why this is surprising
- The config loads and validates fine;
NewScript/validateConfigaccept it. The failure only surfaces mid-session, deep in message building, as a hard crash of the whole process. - The rest of the toolset already treats
descriptionas optional:Tools()falls back withcmp.Or(cfg.Description, ...)anddefaultPropertyTypes()uses a comma-ok assertion.Instructions()is the only code path that hard-requires it.
Suggested fix
description should be either optional or rejected at config load time — anything but a runtime panic:
- Make it optional in
Instructions()(preferred, consistent withTools()): use comma-ok assertions and fall back to an empty/Runs: cmddescription when missing; skip or stringify non-map arg defs. - Or validate at config load: extend
validateConfig()(or schema validation inpkg/config) to require a stringdescriptionper arg and return a clear error liketool 'greet' arg 'name' is missing a description, so the config is refused up front instead of crashing the session.
Happy to provide more detail if useful.
Activity
fix: guard type assertions in ScriptToolSet.Instructions() against mi…