Tool interface¶
ExecutionContext ¶
Tool ¶
A tool is an external program that may require special handling to be executed properly.
execution_context abstractmethod
¶
execution_context(
command: list[str],
) -> Generator[ExecutionContext, None, None]
A context manager bound to the lifecycle of each tool execution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command | list[str] | The command to execute. | required |
Yields:
Type | Description |
---|---|
ExecutionContext | The execution context. |
run ¶
Equivalent to SubprocessRunner.run
with the tool's execution_context
determining the final command and environment variables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command | list[str] | The command to execute. | required |
Other Parameters:
Name | Type | Description |
---|---|---|
**kwargs | Any | Additional keyword arguments to pass to |
capture ¶
Equivalent to SubprocessRunner.capture
with the tool's execution_context
determining the final command and environment variables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command | list[str] | The command to execute. | required |
Other Parameters:
Name | Type | Description |
---|---|---|
**kwargs | Any | Additional keyword arguments to pass to |
wait ¶
Equivalent to SubprocessRunner.wait
with the tool's execution_context
determining the final command and environment variables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command | list[str] | The command to execute. | required |
Other Parameters:
Name | Type | Description |
---|---|---|
**kwargs | Any | Additional keyword arguments to pass to |
exit_with ¶
Equivalent to SubprocessRunner.exit_with
with the tool's execution_context
determining the final command and environment variables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command | list[str] | The command to execute. | required |
Other Parameters:
Name | Type | Description |
---|---|---|
**kwargs | Any | Additional keyword arguments to pass to |
attach ¶
attach(command: list[str], **kwargs: Any) -> CompletedProcess
Equivalent to SubprocessRunner.attach
with the tool's execution_context
determining the final command and environment variables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command | list[str] | The command to execute. | required |
Other Parameters:
Name | Type | Description |
---|---|---|
**kwargs | Any | Additional keyword arguments to pass to |
redirect ¶
redirect(command: list[str], **kwargs: Any) -> CompletedProcess
Equivalent to SubprocessRunner.redirect
with the tool's execution_context
determining the final command and environment variables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command | list[str] | The command to execute. | required |
Other Parameters:
Name | Type | Description |
---|---|---|
**kwargs | Any | Additional keyword arguments to pass to |