Add workflow orchestration for adaptive caching (7/8) by pedrohsdb · Pull Request #4922 · Skyvern-AI/skyvern · GitHub
Skip to content

Add workflow orchestration for adaptive caching (7/8) - #4922

Merged
pedrohsdb merged 1 commit into
mainfrom
repo-sync/pedro/adaptive-caching-pr7-orchestration
Feb 28, 2026
Merged

pedrohsdb merged 1 commit into
mainfrom
repo-sync/pedro/adaptive-caching-pr7-orchestration

Conversation

@pedrohsdb

Copy link
Copy Markdown
Contributor

Synced from cloud PR: https://github.com/Skyvern-AI/skyvern-cloud/pull/8990
Author: @pedrohsdb

Summary

Changes (797 additions, 78 deletions)

skyvern/forge/sdk/workflow/service.py (+765 lines)

The core orchestration changes:

  • Handles code_v2 run mode in the workflow execution path
  • Triggers script review on workflow completion when adaptive caching is enabled
  • Manages fallback episode collection throughout the run lifecycle
  • Coordinates with the script reviewer service to publish improved script revisions
  • Adds generate_script_on_terminal support for auto-generating scripts on terminal workflow states

skyvern/core/script_generations/script_skyvern_page.py (+110 lines)

Extends the script execution page class:

  • Records branch hits during classify() calls for TTL-based pruning
  • Captures fallback episodes when cached script logic fails
  • Routes to surgical_fallback() when targeted AI intervention is needed

Test plan

  • Both files pass py_compile
  • Both files pass ruff lint and format
  • End-to-end test: run a workflow with adaptive_caching=true
  • Verify fallback episodes trigger script review on completion
  • Verify branch hits are recorded and stale branches detected
  • Test generate_script_on_terminal flag behavior

🤖 Generated with Claude Code

Synced from cloud PR: Skyvern-AI/skyvern-cloud#8990
Author: @pedrohsdb

## Summary
- Integrates adaptive caching into the workflow execution lifecycle and script page class — split from #8960
- This is the main production-touching PR — connects all the standalone modules together
- Depends on #8984 (database), #8986 (prompts), #8987 (modules), #8988 (SkyvernPage), #8989 (script gen)

## Changes (797 additions, 78 deletions)

### `skyvern/forge/sdk/workflow/service.py` (+765 lines)
The core orchestration changes:
- Handles `code_v2` run mode in the workflow execution path
- Triggers script review on workflow completion when adaptive caching is enabled
- Manages fallback episode collection throughout the run lifecycle
- Coordinates with the script reviewer service to publish improved script revisions
- Adds `generate_script_on_terminal` support for auto-generating scripts on terminal workflow states

### `skyvern/core/script_generations/script_skyvern_page.py` (+110 lines)
Extends the script execution page class:
- Records branch hits during `classify()` calls for TTL-based pruning
- Captures fallback episodes when cached script logic fails
- Routes to `surgical_fallback()` when targeted AI intervention is needed

## Test plan
- [x] Both files pass `py_compile`
- [x] Both files pass ruff lint and format
- [ ] End-to-end test: run a workflow with adaptive_caching=true
- [ ] Verify fallback episodes trigger script review on completion
- [ ] Verify branch hits are recorded and stale branches detected
- [ ] Test generate_script_on_terminal flag behavior

🤖 Generated with [Claude Code](https://claude.ai/code)
@pedrohsdb
pedrohsdb merged commit feff39b into main Feb 28, 2026
12 checks passed
@pedrohsdb
pedrohsdb deleted the repo-sync/pedro/adaptive-caching-pr7-orchestration branch February 28, 2026 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant