roast-ai 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yaml +2 -2
- data/.gitignore +1 -0
- data/CHANGELOG.md +103 -0
- data/CLAUDE.md +55 -9
- data/Gemfile.lock +19 -10
- data/README.md +69 -3
- data/bin/console +1 -0
- data/docs/AGENT_STEPS.md +33 -9
- data/docs/VALIDATION.md +178 -0
- data/examples/agent_continue/add_documentation/prompt.md +5 -0
- data/examples/agent_continue/add_error_handling/prompt.md +5 -0
- data/examples/agent_continue/analyze_codebase/prompt.md +7 -0
- data/examples/agent_continue/combined_workflow.yml +24 -0
- data/examples/agent_continue/continue_adding_features/prompt.md +4 -0
- data/examples/agent_continue/create_integration_tests/prompt.md +3 -0
- data/examples/agent_continue/document_with_context/prompt.md +5 -0
- data/examples/agent_continue/explore_api/prompt.md +6 -0
- data/examples/agent_continue/implement_client/prompt.md +6 -0
- data/examples/agent_continue/inline_workflow.yml +20 -0
- data/examples/agent_continue/refactor_code/prompt.md +2 -0
- data/examples/agent_continue/verify_changes/prompt.md +6 -0
- data/examples/agent_continue/workflow.yml +27 -0
- data/examples/agent_workflow/workflow.png +0 -0
- data/examples/api_workflow/workflow.png +0 -0
- data/examples/apply_diff_demo/README.md +58 -0
- data/examples/apply_diff_demo/apply_simple_change/prompt.md +13 -0
- data/examples/apply_diff_demo/create_sample_file/prompt.md +11 -0
- data/examples/apply_diff_demo/workflow.yml +24 -0
- data/examples/available_tools_demo/workflow.png +0 -0
- data/examples/bash_prototyping/api_testing.png +0 -0
- data/examples/bash_prototyping/system_analysis.png +0 -0
- data/examples/case_when/workflow.png +0 -0
- data/examples/cmd/basic_workflow.png +0 -0
- data/examples/cmd/dev_workflow.png +0 -0
- data/examples/cmd/explorer_workflow.png +0 -0
- data/examples/conditional/simple_workflow.png +0 -0
- data/examples/conditional/workflow.png +0 -0
- data/examples/context_management_demo/README.md +43 -0
- data/examples/context_management_demo/workflow.yml +42 -0
- data/examples/direct_coerce_syntax/workflow.png +0 -0
- data/examples/dot_notation/workflow.png +0 -0
- data/examples/exit_on_error/workflow.png +0 -0
- data/examples/grading/rb_test_runner +1 -1
- data/examples/grading/workflow.png +0 -0
- data/examples/interpolation/workflow.png +0 -0
- data/examples/interpolation/workflow.yml +1 -1
- data/examples/iteration/workflow.png +0 -0
- data/examples/json_handling/workflow.png +0 -0
- data/examples/mcp/database_workflow.png +0 -0
- data/examples/mcp/env_demo/workflow.png +0 -0
- data/examples/mcp/filesystem_demo/workflow.png +0 -0
- data/examples/mcp/github_workflow.png +0 -0
- data/examples/mcp/multi_mcp_workflow.png +0 -0
- data/examples/mcp/workflow.png +0 -0
- data/examples/no_model_fallback/README.md +17 -0
- data/examples/no_model_fallback/analyze_file/prompt.md +1 -0
- data/examples/no_model_fallback/analyze_patterns/prompt.md +27 -0
- data/examples/no_model_fallback/generate_report_for_md/prompt.md +10 -0
- data/examples/no_model_fallback/generate_report_for_rb/prompt.md +3 -0
- data/examples/no_model_fallback/sample.rb +42 -0
- data/examples/no_model_fallback/workflow.yml +19 -0
- data/examples/openrouter_example/workflow.png +0 -0
- data/examples/pre_post_processing/workflow.png +0 -0
- data/examples/rspec_to_minitest/workflow.png +0 -0
- data/examples/shared_config/example_with_shared_config/workflow.png +0 -0
- data/examples/shared_config/shared.png +0 -0
- data/examples/single_target_prepost/workflow.png +0 -0
- data/examples/smart_coercion_defaults/workflow.png +0 -0
- data/examples/step_configuration/workflow.png +0 -0
- data/examples/swarm_example.yml +25 -0
- data/examples/tool_config_example/workflow.png +0 -0
- data/examples/user_input/funny_name/workflow.png +0 -0
- data/examples/user_input/simple_input_demo/workflow.png +0 -0
- data/examples/user_input/survey_workflow.png +0 -0
- data/examples/user_input/workflow.png +0 -0
- data/examples/workflow_generator/workflow.png +0 -0
- data/lib/roast/errors.rb +3 -0
- data/lib/roast/helpers/timeout_handler.rb +91 -0
- data/lib/roast/services/context_threshold_checker.rb +42 -0
- data/lib/roast/services/token_counting_service.rb +44 -0
- data/lib/roast/tools/apply_diff.rb +128 -0
- data/lib/roast/tools/bash.rb +15 -9
- data/lib/roast/tools/cmd.rb +32 -12
- data/lib/roast/tools/coding_agent.rb +65 -10
- data/lib/roast/tools/context_summarizer.rb +108 -0
- data/lib/roast/tools/swarm.rb +124 -0
- data/lib/roast/version.rb +1 -1
- data/lib/roast/workflow/agent_step.rb +9 -2
- data/lib/roast/workflow/base_iteration_step.rb +3 -2
- data/lib/roast/workflow/base_workflow.rb +41 -2
- data/lib/roast/workflow/command_executor.rb +3 -1
- data/lib/roast/workflow/configuration.rb +2 -1
- data/lib/roast/workflow/configuration_loader.rb +63 -1
- data/lib/roast/workflow/configuration_parser.rb +2 -0
- data/lib/roast/workflow/context_manager.rb +89 -0
- data/lib/roast/workflow/each_step.rb +1 -1
- data/lib/roast/workflow/input_step.rb +2 -0
- data/lib/roast/workflow/interpolator.rb +23 -1
- data/lib/roast/workflow/output_handler.rb +1 -1
- data/lib/roast/workflow/repeat_step.rb +1 -1
- data/lib/roast/workflow/replay_handler.rb +1 -1
- data/lib/roast/workflow/sqlite_state_repository.rb +342 -0
- data/lib/roast/workflow/state_manager.rb +2 -2
- data/lib/roast/workflow/state_repository_factory.rb +36 -0
- data/lib/roast/workflow/step_completion_reporter.rb +27 -0
- data/lib/roast/workflow/step_executor_coordinator.rb +19 -18
- data/lib/roast/workflow/step_executor_with_reporting.rb +68 -0
- data/lib/roast/workflow/step_loader.rb +1 -1
- data/lib/roast/workflow/step_name_extractor.rb +84 -0
- data/lib/roast/workflow/validation_command.rb +197 -0
- data/lib/roast/workflow/validators/base_validator.rb +44 -0
- data/lib/roast/workflow/validators/dependency_validator.rb +223 -0
- data/lib/roast/workflow/validators/linting_validator.rb +113 -0
- data/lib/roast/workflow/validators/schema_validator.rb +90 -0
- data/lib/roast/workflow/validators/step_collector.rb +57 -0
- data/lib/roast/workflow/validators/validation_orchestrator.rb +52 -0
- data/lib/roast/workflow/workflow_executor.rb +11 -4
- data/lib/roast/workflow/workflow_initializer.rb +80 -0
- data/lib/roast/workflow/workflow_runner.rb +6 -0
- data/lib/roast/workflow_diagram_generator.rb +298 -0
- data/lib/roast.rb +158 -0
- data/roast.gemspec +4 -1
- data/schema/workflow.json +77 -1
- metadata +129 -1
data/docs/VALIDATION.md
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
# Workflow Validation
|
2
|
+
|
3
|
+
Roast provides comprehensive validation for workflow configurations to catch errors early and improve the development experience.
|
4
|
+
|
5
|
+
## Using the Validation Command
|
6
|
+
|
7
|
+
### Validate a Single Workflow
|
8
|
+
|
9
|
+
```bash
|
10
|
+
# Validate a specific workflow by path
|
11
|
+
roast validate path/to/workflow.yml
|
12
|
+
|
13
|
+
# Or by workflow name (assumes roast/ directory structure)
|
14
|
+
roast validate my_workflow
|
15
|
+
```
|
16
|
+
|
17
|
+
### Validate All Workflows
|
18
|
+
|
19
|
+
```bash
|
20
|
+
# Validate all workflows in the roast/ directory
|
21
|
+
roast validate
|
22
|
+
```
|
23
|
+
|
24
|
+
### Strict Mode
|
25
|
+
|
26
|
+
Use the `--strict` or `-s` flag to treat warnings as errors:
|
27
|
+
|
28
|
+
```bash
|
29
|
+
roast validate --strict
|
30
|
+
```
|
31
|
+
|
32
|
+
## Validation Levels
|
33
|
+
|
34
|
+
### 1. Schema Validation
|
35
|
+
|
36
|
+
Ensures your workflow conforms to the JSON schema:
|
37
|
+
- Required fields (name, tools, steps)
|
38
|
+
- Correct data types
|
39
|
+
- Valid structure for complex steps (if/then, case/when, each, repeat)
|
40
|
+
|
41
|
+
### 2. Dependency Checking
|
42
|
+
|
43
|
+
#### Tool Dependencies
|
44
|
+
Validates that all declared tools are available:
|
45
|
+
- Checks for tool module existence
|
46
|
+
- Supports MCP tool configurations
|
47
|
+
- Provides helpful suggestions for typos
|
48
|
+
|
49
|
+
#### Step References
|
50
|
+
Validates that steps referenced in conditions exist:
|
51
|
+
- Checks `if`, `unless`, and `case` conditions
|
52
|
+
- Distinguishes between step references and expressions
|
53
|
+
|
54
|
+
#### Resource Dependencies
|
55
|
+
Validates file resources:
|
56
|
+
- Warns if target files don't exist (unless using glob patterns)
|
57
|
+
- Checks for missing prompt files
|
58
|
+
|
59
|
+
### 3. Configuration Linting
|
60
|
+
|
61
|
+
#### Naming Conventions
|
62
|
+
- Workflows should have descriptive names
|
63
|
+
- Step names should use snake_case
|
64
|
+
|
65
|
+
#### Complexity Checks
|
66
|
+
- Warns about workflows with too many steps (>20)
|
67
|
+
- Detects excessive nesting depth (>5 levels)
|
68
|
+
|
69
|
+
|
70
|
+
#### Best Practices
|
71
|
+
- Warns about missing error handling
|
72
|
+
- Detects unused tool declarations
|
73
|
+
|
74
|
+
## Error Messages
|
75
|
+
|
76
|
+
The validator provides clear, actionable error messages:
|
77
|
+
|
78
|
+
```
|
79
|
+
Workflow validation failed with 2 error(s):
|
80
|
+
|
81
|
+
• Missing required field: 'steps' (Add 'steps' to your workflow configuration)
|
82
|
+
• Tool 'Roast::Tools::BashCommand' is not available (Did you mean: Roast::Tools::Bash?)
|
83
|
+
```
|
84
|
+
|
85
|
+
## Example Workflow
|
86
|
+
|
87
|
+
Here's an example of a well-validated workflow:
|
88
|
+
|
89
|
+
```yaml
|
90
|
+
name: Data Processing Workflow
|
91
|
+
tools:
|
92
|
+
- Roast::Tools::Bash
|
93
|
+
- Roast::Tools::ReadFile
|
94
|
+
- Roast::Tools::WriteFile
|
95
|
+
|
96
|
+
# Use inputs for sensitive data
|
97
|
+
inputs:
|
98
|
+
- api_token: "Enter your API token"
|
99
|
+
|
100
|
+
# Enable error handling
|
101
|
+
exit_on_error: true
|
102
|
+
|
103
|
+
steps:
|
104
|
+
- validate_input
|
105
|
+
- fetch_data
|
106
|
+
- process_data
|
107
|
+
- save_results
|
108
|
+
```
|
109
|
+
|
110
|
+
## Integration with CI/CD
|
111
|
+
|
112
|
+
You can integrate workflow validation into your CI/CD pipeline:
|
113
|
+
|
114
|
+
```yaml
|
115
|
+
# .github/workflows/validate.yml
|
116
|
+
name: Validate Workflows
|
117
|
+
on: [push, pull_request]
|
118
|
+
|
119
|
+
jobs:
|
120
|
+
validate:
|
121
|
+
runs-on: ubuntu-latest
|
122
|
+
steps:
|
123
|
+
- uses: actions/checkout@v2
|
124
|
+
- uses: ruby/setup-ruby@v1
|
125
|
+
with:
|
126
|
+
ruby-version: '3.0'
|
127
|
+
bundler-cache: true
|
128
|
+
- name: Validate all workflows
|
129
|
+
run: bundle exec roast validate --strict
|
130
|
+
```
|
131
|
+
|
132
|
+
## Programmatic Usage
|
133
|
+
|
134
|
+
You can also use the validator programmatically:
|
135
|
+
|
136
|
+
```ruby
|
137
|
+
require 'roast'
|
138
|
+
|
139
|
+
yaml_content = File.read('workflow.yml')
|
140
|
+
validator = Roast::Workflow::Validators::ValidationOrchestrator.new(yaml_content, 'workflow.yml')
|
141
|
+
|
142
|
+
if validator.valid?
|
143
|
+
puts "Workflow is valid!"
|
144
|
+
|
145
|
+
# Check for warnings
|
146
|
+
validator.warnings.each do |warning|
|
147
|
+
puts "Warning: #{warning[:message]}"
|
148
|
+
puts " → #{warning[:suggestion]}"
|
149
|
+
end
|
150
|
+
else
|
151
|
+
# Handle errors
|
152
|
+
validator.errors.each do |error|
|
153
|
+
puts "Error: #{error[:message]}"
|
154
|
+
puts " → #{error[:suggestion]}"
|
155
|
+
end
|
156
|
+
end
|
157
|
+
```
|
158
|
+
|
159
|
+
## Architecture
|
160
|
+
|
161
|
+
The validation system follows SOLID principles with a modular design:
|
162
|
+
|
163
|
+
- **ValidationOrchestrator**: Coordinates all validators and aggregates results
|
164
|
+
- **SchemaValidator**: Handles YAML parsing and JSON schema validation
|
165
|
+
- **DependencyValidator**: Validates tools, step references, and resources
|
166
|
+
- **LintingValidator**: Enforces best practices and code quality standards
|
167
|
+
- **StepCollector**: Provides efficient caching for step traversal
|
168
|
+
|
169
|
+
This architecture makes it easy to extend validation with new rules or customize existing behavior.
|
170
|
+
|
171
|
+
## Future Enhancements
|
172
|
+
|
173
|
+
The validation system is designed to be extensible. Future enhancements may include:
|
174
|
+
|
175
|
+
- Detection of circular dependencies
|
176
|
+
- Performance analysis and optimization suggestions
|
177
|
+
- Custom validation rules via plugins
|
178
|
+
- Integration with language servers for real-time validation
|
@@ -0,0 +1,24 @@
|
|
1
|
+
description: Example combining both continue and context summary features
|
2
|
+
|
3
|
+
# This example shows how both parameters can work together for complex workflows
|
4
|
+
|
5
|
+
steps:
|
6
|
+
# Initial exploration
|
7
|
+
- explore_api
|
8
|
+
|
9
|
+
# First coding agent task
|
10
|
+
- ^implement_client
|
11
|
+
|
12
|
+
# Continue with context awareness
|
13
|
+
- ^add_error_handling
|
14
|
+
|
15
|
+
# Final implementation with full context
|
16
|
+
- ^create_integration_tests
|
17
|
+
|
18
|
+
add_error_handling:
|
19
|
+
continue: true # Continue working on the same client
|
20
|
+
include_context_summary: true # Include context about what was explored and built
|
21
|
+
|
22
|
+
create_integration_tests:
|
23
|
+
continue: true # Continue in the same session
|
24
|
+
include_context_summary: true # Full context of implementation
|
@@ -0,0 +1,20 @@
|
|
1
|
+
description: Example workflow using inline agent prompts with continuation
|
2
|
+
|
3
|
+
# This example demonstrates using inline agent prompts (direct text after ^)
|
4
|
+
# combined with the new parameters
|
5
|
+
|
6
|
+
steps:
|
7
|
+
# Start with a fresh context
|
8
|
+
- ^Create a simple Ruby class for managing a todo list with add, remove, and list methods
|
9
|
+
|
10
|
+
# Continue from previous session to add more features
|
11
|
+
- ^continue_adding_features
|
12
|
+
|
13
|
+
# Use context summary to understand what was built
|
14
|
+
- ^document_with_context
|
15
|
+
|
16
|
+
continue_adding_features:
|
17
|
+
continue: true # This continues from the previous agent session
|
18
|
+
|
19
|
+
document_with_context:
|
20
|
+
include_context_summary: true # This will include context about previous steps
|
@@ -0,0 +1,27 @@
|
|
1
|
+
description: Example workflow demonstrating agent continuation and context summary features
|
2
|
+
|
3
|
+
# This example shows how to use the new coding agent parameters:
|
4
|
+
# - continue: true - continues from previous agent session
|
5
|
+
# - include_context_summary: true - includes workflow context in the prompt
|
6
|
+
|
7
|
+
target: "**/*.rb"
|
8
|
+
|
9
|
+
steps:
|
10
|
+
# First agent step - starts fresh
|
11
|
+
- ^analyze_codebase
|
12
|
+
|
13
|
+
# Second agent step - continues from previous session
|
14
|
+
- ^refactor_code
|
15
|
+
|
16
|
+
# Third agent step - includes context summary from previous steps
|
17
|
+
- ^add_documentation
|
18
|
+
|
19
|
+
# Final verification step
|
20
|
+
- verify_changes
|
21
|
+
|
22
|
+
# Step configurations
|
23
|
+
refactor_code:
|
24
|
+
continue: true # Continue from the previous agent session
|
25
|
+
|
26
|
+
add_documentation:
|
27
|
+
include_context_summary: true # Include workflow context in the prompt
|
Binary file
|
Binary file
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Apply Diff Demo
|
2
|
+
|
3
|
+
This example demonstrates the `apply_diff` tool, which shows users a colored diff of proposed changes and applies them only after user confirmation.
|
4
|
+
|
5
|
+
## What this workflow does
|
6
|
+
|
7
|
+
1. **Creates a sample file** - Generates `hello.txt` with simple text content
|
8
|
+
2. **Applies a simple change** - Uses `apply_diff` to modify the greeting and ask for user confirmation
|
9
|
+
|
10
|
+
## Key features demonstrated
|
11
|
+
|
12
|
+
- **Interactive approval** - The `apply_diff` tool shows a clear, colored diff and waits for user confirmation
|
13
|
+
- **Safe modifications** - Changes are only applied when the user explicitly approves them
|
14
|
+
- **Colored visualization** - Diff format shows exactly what will be changed with:
|
15
|
+
- **Red** lines starting with `-` for removed content
|
16
|
+
- **Green** lines starting with `+` for added content
|
17
|
+
- **Cyan** line numbers and context (`@@` lines)
|
18
|
+
- **Bold** diff headers
|
19
|
+
- **Optional descriptions** - You can provide context about why a change is being made
|
20
|
+
|
21
|
+
## Running the workflow
|
22
|
+
|
23
|
+
```bash
|
24
|
+
bin/roast examples/apply_diff_demo/workflow.yml
|
25
|
+
```
|
26
|
+
|
27
|
+
## Expected interaction
|
28
|
+
|
29
|
+
When you run this workflow, you'll see:
|
30
|
+
|
31
|
+
1. The workflow creates a simple `hello.txt` file
|
32
|
+
2. It proposes changing "Hello World!" to "Hello, Apply Diff Demo!"
|
33
|
+
3. It shows you a colored diff of the proposed change:
|
34
|
+
```
|
35
|
+
📝 Proposed change for hello.txt:
|
36
|
+
Description: Update greeting to be more specific to the demo
|
37
|
+
|
38
|
+
diff --git a/hello.txt b/hello.txt
|
39
|
+
index 1234567..abcdefg 100644
|
40
|
+
--- a/hello.txt
|
41
|
+
+++ b/hello.txt
|
42
|
+
@@ -1,3 +1,3 @@
|
43
|
+
-Hello World!
|
44
|
+
+Hello, Apply Diff Demo!
|
45
|
+
This is a demo file.
|
46
|
+
We will modify this file in the next step.
|
47
|
+
```
|
48
|
+
4. It asks for your confirmation: `Apply this change? (y/n)`
|
49
|
+
5. If you say "y", it applies the change; if "n", it cancels
|
50
|
+
6. Finally, it reads the file again to show the result
|
51
|
+
|
52
|
+
## Tools used
|
53
|
+
|
54
|
+
- `Roast::Tools::WriteFile` - Creates the initial sample file
|
55
|
+
- `Roast::Tools::ReadFile` - Reads files to show results
|
56
|
+
- `Roast::Tools::ApplyDiff` - Shows colored diffs and applies changes with user confirmation
|
57
|
+
|
58
|
+
This pattern is useful for any workflow where you want to make targeted changes to files but give users control over what actually gets applied.
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Apply Simple Change
|
2
|
+
|
3
|
+
Now use the apply_diff function to modify the `hello.txt` file. Let's change the greeting from "Hello World!" to "Hello, Apply Diff Demo!".
|
4
|
+
|
5
|
+
Use the apply_diff function with:
|
6
|
+
- `file_path`: "hello.txt"
|
7
|
+
- `old_content`: "Hello World!"
|
8
|
+
- `new_content`: "Hello, Apply Diff Demo!"
|
9
|
+
- `description`: "Update greeting to be more specific to the demo"
|
10
|
+
|
11
|
+
This will show the user a colored diff of the proposed change and ask for their confirmation before applying it.
|
12
|
+
|
13
|
+
After the change is applied (or declined), read the file again to show the final result.
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Apply Diff Demo
|
2
|
+
#
|
3
|
+
# This workflow demonstrates the apply_diff tool which shows users a diff
|
4
|
+
# and applies changes based on their confirmation. It's useful for making
|
5
|
+
# targeted changes to files with user approval.
|
6
|
+
|
7
|
+
name: Apply Diff Demo
|
8
|
+
model: gpt-4o-mini
|
9
|
+
|
10
|
+
tools:
|
11
|
+
- Roast::Tools::WriteFile
|
12
|
+
- Roast::Tools::ReadFile
|
13
|
+
- Roast::Tools::ApplyDiff
|
14
|
+
|
15
|
+
steps:
|
16
|
+
- create_sample_file
|
17
|
+
- apply_simple_change
|
18
|
+
|
19
|
+
# Step configurations
|
20
|
+
create_sample_file:
|
21
|
+
print_response: false
|
22
|
+
|
23
|
+
apply_simple_change:
|
24
|
+
print_response: true
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Context Management Demo
|
2
|
+
|
3
|
+
This example demonstrates Roast's automatic context management feature, which helps prevent workflow failures when conversation history exceeds the LLM's context window.
|
4
|
+
|
5
|
+
## Features Demonstrated
|
6
|
+
|
7
|
+
1. **Automatic Token Tracking**: Monitors token usage throughout workflow execution
|
8
|
+
2. **Configurable Thresholds**: Set when to trigger warnings or compaction
|
9
|
+
3. **Context Preservation**: Specify critical steps to retain during compaction
|
10
|
+
|
11
|
+
## Configuration
|
12
|
+
|
13
|
+
```yaml
|
14
|
+
context_management:
|
15
|
+
enabled: true # Enable context management
|
16
|
+
strategy: auto # Compaction strategy (auto, summarize, prune, none)
|
17
|
+
threshold: 0.8 # Trigger at 80% of context window
|
18
|
+
max_tokens: 10000 # Override default limit (for demo purposes)
|
19
|
+
retain_steps: # Steps to always keep in full
|
20
|
+
- analyze_requirements
|
21
|
+
- generate_summary
|
22
|
+
```
|
23
|
+
|
24
|
+
## Running the Demo
|
25
|
+
|
26
|
+
```bash
|
27
|
+
roast execute context_management_demo
|
28
|
+
```
|
29
|
+
|
30
|
+
The workflow intentionally generates verbose responses to demonstrate how context management handles large amounts of text without failing.
|
31
|
+
|
32
|
+
## What to Observe
|
33
|
+
|
34
|
+
1. **Token Usage Warnings**: Watch for warnings as the context approaches limits
|
35
|
+
2. **Automatic Handling**: The workflow continues even with large outputs
|
36
|
+
3. **Preserved Context**: Critical steps remain accessible throughout execution
|
37
|
+
|
38
|
+
## Customization
|
39
|
+
|
40
|
+
Try modifying the configuration:
|
41
|
+
- Lower `max_tokens` to trigger compaction sooner
|
42
|
+
- Change `strategy` to test different compaction approaches
|
43
|
+
- Add more steps to `retain_steps` to preserve additional context
|
@@ -0,0 +1,42 @@
|
|
1
|
+
name: Context Management Demo
|
2
|
+
tools:
|
3
|
+
- Roast::Tools::ReadFile
|
4
|
+
- Roast::Tools::WriteFile
|
5
|
+
|
6
|
+
# Context management configuration
|
7
|
+
context_management:
|
8
|
+
enabled: true
|
9
|
+
strategy: auto
|
10
|
+
threshold: 0.8 # Trigger compaction at 80% of context window
|
11
|
+
max_tokens: 10000 # Demo with smaller limit for testing
|
12
|
+
retain_steps:
|
13
|
+
- analyze_requirements
|
14
|
+
- generate_summary
|
15
|
+
|
16
|
+
steps:
|
17
|
+
- analyze_requirements: |
|
18
|
+
Analyze this text and list the key requirements:
|
19
|
+
|
20
|
+
We need a system that can:
|
21
|
+
1. Process customer orders
|
22
|
+
2. Track inventory levels
|
23
|
+
3. Generate reports
|
24
|
+
4. Handle refunds
|
25
|
+
5. Integrate with payment systems
|
26
|
+
|
27
|
+
- expand_details: |
|
28
|
+
For each requirement from the previous step, provide detailed implementation notes,
|
29
|
+
technical considerations, and potential challenges. Be very thorough and verbose
|
30
|
+
to help test the context management system.
|
31
|
+
|
32
|
+
- generate_more_context: |
|
33
|
+
Now describe the database schema needed for this system. Include all tables,
|
34
|
+
relationships, indexes, and data types. Be extremely detailed.
|
35
|
+
|
36
|
+
- add_api_design: |
|
37
|
+
Design a complete REST API for this system. Include all endpoints, request/response
|
38
|
+
formats, authentication, and error handling. Provide examples for each endpoint.
|
39
|
+
|
40
|
+
- generate_summary: |
|
41
|
+
Create a concise executive summary of the system design. Focus on the key decisions
|
42
|
+
and trade-offs made during the design process.
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# No Model Fallback Example
|
2
|
+
|
3
|
+
This example demonstrates the issue where workflows without explicit model specification do not properly fall back to a default model.
|
4
|
+
|
5
|
+
## Purpose
|
6
|
+
|
7
|
+
This workflow is based on the interpolation example but intentionally omits the `model` field to test the fallback behavior.
|
8
|
+
|
9
|
+
## Expected Behavior
|
10
|
+
|
11
|
+
The workflow should fall back to a default model when no model is specified at the workflow level.
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
```bash
|
16
|
+
bin/roast examples/no_model_fallback/workflow.yml --file examples/no_model_fallback/sample.rb
|
17
|
+
```
|
@@ -0,0 +1 @@
|
|
1
|
+
Analyze the file at: <%= workflow.file %>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Extract some patterns about this file and return in json format like this:
|
2
|
+
|
3
|
+
<json>
|
4
|
+
{
|
5
|
+
"code_patterns": {
|
6
|
+
"class_structure": {
|
7
|
+
"name": "Calculator",
|
8
|
+
"instance_variables": ["@memory"],
|
9
|
+
"method_count": 7,
|
10
|
+
"method_types": {
|
11
|
+
"constructor": ["initialize"],
|
12
|
+
"operations": ["add", "subtract", "multiply", "divide"],
|
13
|
+
"accessors": ["memory"],
|
14
|
+
"utility": ["clear"]
|
15
|
+
}
|
16
|
+
},
|
17
|
+
"error_handling": {
|
18
|
+
"techniques": ["conditional raise", "zero check"],
|
19
|
+
"examples": ["raise \"Division by zero!\" if number.zero?"]
|
20
|
+
},
|
21
|
+
"design_patterns": {
|
22
|
+
"state": "Uses instance variable to maintain calculator state",
|
23
|
+
"command": "Each operation method modifies the internal state"
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
27
|
+
</json>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Generate a comprehensive report for the markdown file.
|
2
|
+
|
3
|
+
File content: {{steps.analyze_file}}
|
4
|
+
|
5
|
+
Patterns found: {{steps.analyze_patterns}}
|
6
|
+
|
7
|
+
Please create a detailed report that includes:
|
8
|
+
1. Summary of the file content
|
9
|
+
2. Key patterns identified
|
10
|
+
3. Any recommendations or observations
|