Tool bundle configuration
sweagent.tools.commands.Command
pydantic-model
Bases: BaseModel
Represents an executable command with arguments and documentation.
A command can be either a simple bash command or a multi-line command terminated by an end marker.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The command name |
docstring |
str | None
|
Human readable description of what the command does |
signature |
str | None
|
Optional custom signature override |
end_name |
str | None
|
For multi-line commands, the terminating marker |
arguments |
list[Argument]
|
List of arguments accepted by the command |
Properties
invoke_format: Format string for constructing the full command invocation
Fields:
-
name
(str
) -
docstring
(str | None
) -
signature
(str | None
) -
end_name
(str | None
) -
arguments
(list[Argument]
) -
invoke_format
(str
)
Validators:
docstring
pydantic-field
docstring: str | None
end_name
pydantic-field
end_name: str | None = None
invoke_format
pydantic-field
invoke_format: str
Gets the format string for invoking this command with arguments.
Returns either the custom signature with argument placeholders replaced, or a default format of "command arg1 arg2 ...".
name
pydantic-field
name: str
signature
pydantic-field
signature: str | None = None
get_function_calling_tool
get_function_calling_tool() -> dict
Converts this command into an OpenAI function calling tool definition.
Returns:
Type | Description |
---|---|
dict
|
Dict containing the OpenAI function schema for this command |
Source code in sweagent/tools/commands.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
validate_arguments
pydantic-validator
validate_arguments() -> Command
Validates command argument configuration.
Checks: - Required arguments come before optional ones - Argument names are unique - Argument names match the pattern - Arguments match the signature
Returns:
Type | Description |
---|---|
Command
|
The validated Command instance |
Raises:
Type | Description |
---|---|
ValueError
|
If validation fails |
Source code in sweagent/tools/commands.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
|
sweagent.tools.commands.Argument
pydantic-model
Bases: BaseModel
Fields:
-
name
(str
) -
type
(str
) -
items
(dict[str, str] | None
) -
description
(str
) -
required
(bool
) -
enum
(list[str] | None
) -
argument_format
(str
)
Validators:
argument_format
pydantic-field
argument_format: str = '{{value}}'
How to invoke the argument in the command. Make sure to use jinja syntax ({{value}}) instead of {value}).
description
pydantic-field
description: str
enum
pydantic-field
enum: list[str] | None = None
items
pydantic-field
items: dict[str, str] | None = None
name
pydantic-field
name: str
required
pydantic-field
required: bool
type
pydantic-field
type: str
validate_argument_format
pydantic-validator
validate_argument_format(value: str) -> str
Source code in sweagent/tools/commands.py
72 73 74 75 |
|