> For the complete documentation index, see [llms.txt](https://underdogcowboy.gitbook.io/underdogcowboy-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://underdogcowboy.gitbook.io/underdogcowboy-docs/tools/interventionmanager.md).

# InterventionManager

The `InterventionManager` is a powerful tool that enhances the development and execution of dialog-based scripts, offering significant benefits for both developers and end-users.

### Key Features

1. **Iterative Development**: In IDEs or IPython notebooks, the `InterventionManager` allows developers to pause script execution and interact with the dialog in real-time. This feature is invaluable for testing, debugging, and fine-tuning agent responses without the need to restart the entire script.
2. **Agent Tuning**: Developers can use the intervention feature to explore different conversation paths, assess the agent's responses to various inputs, and make immediate adjustments to improve performance and accuracy.
3. **Human-in-the-Loop Functionality**: For production scripts, the `InterventionManager` enables seamless integration of human oversight. This allows for real-time monitoring, intervention in complex scenarios, and the ability to guide conversations when needed, ensuring higher quality interactions and outcomes.
4. **Educational Tool**: The `InterventionManager` serves as an excellent learning aid, allowing developers and researchers to gain insights into the decision-making processes of AI agents and experiment with different prompts or conversation strategies.
5. **Flexible Command Mode**: The built-in command mode provides a powerful interface for developers to manipulate the dialog timeline, adjust model parameters, or execute custom commands during runtime, offering unparalleled control and flexibility.

### Usage

To use the `InterventionManager`, you'll need to import it and create an instance, passing in your `DialogManager` instance:

```python
from underdogcowboy import DialogManager, InterventionManager

dm = DialogManager()
# Load a pre-saved dialog
agent = dm.load_dialog('/path/to/dialog.json')

intervention_manager = InterventionManager(dm)
intervention_manager.intervene()
```

When you call the `intervene()` method, the script will pause, and the `InterventionManager` will enter an interactive mode, allowing you to:

* Send messages to the agent and receive responses
* Execute commands to manipulate the dialog or the underlying models
* Refine the agent's behavior and responses

### Syntactic Sugar: +adm

The `underdogcowboy` library also provides a syntactic sugar feature, where you can use the `+adm` command to activate the `InterventionManager` in your script. This allows you to easily transition between regular script execution and the interactive intervention mode.

```python
# In your script
response = gitbookdoc >> "Hi my friend, ready for making some documentation?"
print(response)

# Add +adm to enter intervention mode
+adm
```

By incorporating the `InterventionManager` and utilizing the `+adm` feature, you can significantly enhance the development, testing, and production-ready deployment of your dialog-based AI applications.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://underdogcowboy.gitbook.io/underdogcowboy-docs/tools/interventionmanager.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
