Skip to content

Conversation

@loic-carbonne
Copy link

Hi,

This example does not work and is misleading. It seems that there is no possible reuse of cache with parameterized workflows now. Each new instruction generate a new cache key.

Refering to issue #1219

@changeset-bot
Copy link

changeset-bot bot commented Nov 3, 2025

⚠️ No Changeset found

Latest commit: 63cb0c9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Greptile Summary

This PR removes a misleading documentation section about parameterized agent workflows that incorrectly suggested cache reuse across different instructions. The removed example showed a function executeLogin that claimed the same cache could be reused for different username/password combinations, but this is incorrect since Stagehand's caching system generates unique cache keys based on instruction content. Each different instruction creates a separate cache entry, making the documented behavior impossible. This fix prevents user confusion about Stagehand's caching capabilities and aligns the documentation with the actual implementation behavior.

Important Files Changed

Filename Score Overview
packages/docs/v3/best-practices/deterministic-agent.mdx 5/5 Removes misleading parameterized workflow example that incorrectly claimed cache reuse across different instructions

Confidence score: 5/5

  • This PR is safe to merge with minimal risk as it only removes incorrect documentation
  • Score reflects the straightforward nature of removing misleading content that could confuse users about caching behavior
  • No files require special attention beyond the documentation fix

Sequence Diagram

sequenceDiagram
    participant User
    participant Stagehand
    participant Agent
    participant Cache
    participant LLM
    participant Browser

    User->>Stagehand: "new Stagehand({ cacheDir: 'cache/workflow' })"
    User->>Stagehand: "init()"
    User->>Stagehand: "agent()"
    Stagehand->>Agent: "create agent instance"
    
    User->>Agent: "execute({ instruction: 'Complete workflow', maxSteps: 10 })"
    Agent->>Cache: "check for cached actions"
    
    alt First Run (Cache Miss)
        Cache-->>Agent: "no cached actions found"
        Agent->>LLM: "request workflow exploration"
        LLM-->>Agent: "action sequence"
        Agent->>Browser: "execute actions"
        Browser-->>Agent: "action results"
        Agent->>Cache: "save actions to cache"
        Agent-->>User: "result (20-30s, ~50k tokens)"
    else Subsequent Run (Cache Hit)
        Cache-->>Agent: "return cached actions"
        Agent->>Browser: "replay cached actions"
        Browser-->>Agent: "action results"
        Agent-->>User: "result (2-3s, 0 tokens)"
    end
    
    User->>Stagehand: "close()"
Loading

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant