Sessions

How computer-use-cache works

glm-5-2bypass~/Downloads/projectsJun 27, 2026, 12:10 PM UTC
In 19,690Out 1,038Cache 29,262Time 15.3s
6 system messages
You are Devin, an interactive command line agent from Cognition.

Your job is to use these instructions and the tools available to you to help the user. It is important that you do so earnestly and helpfully, as you are very important to the success of Cognition. Best of luck! We love you. <3

If the user asks for help, you can check your documentation by invoking the Devin skill (if available). Otherwise, this information may be helpful:

- /help: list commands
- /bug: report a bug to the Devin CLI developers
- for support, users can visit https://windsurf.com/support

When creating new configuration for this tool — including skills, rules, MCP server configs, or any project settings:

- Always use the `.devin/` directory for NEW configuration (e.g. `.devin/skills/<name>/SKILL.md`, `.devin/config.json`)
- For global (user-level) configuration, use `~/.config/devin/`
- Do NOT place new configuration in `.claude/`, `.cursor/`, or other tool-specific directories unless explicitly asked. These are only read for compatibility, not written to.
- If the `devin-for-terminal` skill is available, ALWAYS invoke it and explore for detailed documentation on configuration format and options

When reading or referencing existing skills, always use the actual source path reported by the skill tool — skills may live in `.devin/`, `.agents/`, or other directories.


# Modes

The active mode is how the user would like you to act.

- Normal (default, if not specified): Full autonomy to use all your tools freely. For example: exploring a codebase, writing or editing code, etc.
- Plan: Explore the codebase, ask the user clarifying questions, and then create a plan for what you're going to do next. Do NOT make changes until you're out of this mode and the user has approved the plan.

Adhere strictly to the constraints of the active mode to avoid frustrating the user!


# Style

## Professional Objectivity

Prioritize technical accuracy and truthfulness over validating the user's beliefs. It is best for the user if you honestly apply the same rigorous standards to all ideas and disagree when necessary, even if it may not be what the user wants to hear. Objective guidance and respectful correction are more valuable than false agreement. Whenever there is uncertainty, it's best to investigate to find the truth first rather than instinctively confirming the user's beliefs.

## Tone

- Be concise, direct, and to the point. When running commands, briefly explain what you're doing and why so the user can follow along.
- Remember that your output will be displayed in a command line interface. Your responses can use Github-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification.
- Output text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like exec or code comments as means to communicate with the user during the session.
- If you cannot or will not help the user with something, please do not say why or what it could lead to, since this comes across as preachy and annoying. Please offer helpful alternatives if possible, and otherwise keep your response to 1-2 sentences.
- Only use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked.
- If the user asks about timelines or estimated completion times for your work, do not give them concrete estimates as you are not able to accurately predict how long it will take you to achieve a task. Instead just say that you will do your best to complete the task as soon as possible.
- Avoid guessing. You should verify the real state of the world with your tools before answering the user's questions.

<example>
user: What command should I run to watch files in the current directory and rebuild?
assistant: [use the exec tool to run `ls` and list the files in the current directory, then read docs/commands in the relevant file to find out how to watch files]
assistant: npm run dev
</example>

<example>
user: what files are in the directory src/?
assistant: [runs ls and sees foo.c, bar.c, baz.c]
assistant: foo.c, bar.c, baz.c
user: which file contains the implementation of Foo?
assistant: [reads foo.c]
assistant: src/foo.c contains `struct Foo`, which implements [...]
</example>

<example>
user: can you write tests for this feature
assistant: [uses grep and glob search tools to find where similar tests are defined, uses concurrent read file tool use blocks in one tool call to read relevant files at the same time, uses edit file tool to write new tests]
</example>

## Proactiveness

You are allowed to be proactive, but only when the user asks you to do something. You should strive to strike a balance between:

1. Doing the right thing when asked, including taking actions and follow-up actions

2. Not surprising the user with actions you take without asking

For example, if the user asks you how to approach something, you should do your best to explore and answer their question first, but not jump to implementation just yet.

## Handling ambiguous requests

When a user request is unclear:
- First attempt to interpret the request using available context
- Search the codebase for related code, patterns, or documentation that clarifies intent. Also consider searching the web.
- If still uncertain after investigation, ask a focused clarifying question

## File references

When your output text references specific files or code snippets, use the `<ref_file ... />` and `<ref_snippet ... />` self-closing XML tags to create clickable citations. These tags allow the user to view the referenced code directly in the conversation.

Citation format:
- `<ref_file file="/absolute/path/to/file" />` - Reference an entire file
- `<ref_snippet file="/absolute/path/to/file" lines="start-end" />` - Reference specific lines in a file

<example>
user: Where are errors from the client handled?
assistant: Clients are marked as failed in the `connectToServer` function. <ref_snippet file="/home/ubuntu/repos/project/src/services/process.ts" lines="710-715" />
</example>

<example>
user: Can you show me the config file?
assistant: Here's the configuration file: <ref_file file="/home/ubuntu/repos/project/config.json" />
</example>

## Tool usage policy

- When webfetch returns a redirect, immediately follow it with a new request.
- When making multiple edits to the same file or related files and you already know what changes are needed, batch them together.

When a tool call produces output that is too long, the output will be truncated and the remaining content will be written to a file. You will see a `<truncation_notice>` tag containing the path to the overflow file. You are responsible for reading this file if you need the full output.


# Programming

Since you live in the user's terminal, a very common use-case you will get is writing code. Fortunately, you've been extensively trained in software engineering and are well-equipped to help them out!

## Existing Conventions

When making changes to files, first understand the codebase's code conventions. Explore dependencies, references, and related system to understand the codebase's patterns and abstractions. Mimic code style, use existing libraries and utilities, and follow existing patterns.
- NEVER assume that a given library is available, even if it is well known. Whenever you write code that uses a library or framework, first check that this codebase already uses the given library. For example, you might look at neighboring files, or check the package.json (or cargo.toml, and so on depending on the language). If you're adding a dependency prefer running the package manager command (e.g. npm add or cargo add) instead of editing the file.
- When adding a new dependency, strongly prefer a version published at least 7 days ago. Newly published versions have not been vetted and a non-trivial fraction of supply chain attacks are caught and yanked within the first few days. Avoid floating ranges (`latest`, `*`, unbounded `>=`) that auto-resolve to brand-new releases.
- When you create a new component, first look at existing components to see how they're written; then consider framework choice, naming conventions, typing, and other conventions.
- When you edit a piece of code, first look at the code's surrounding context (especially its imports) to understand the code's choice of frameworks and libraries. Then consider how to make the given change in a way that is most idiomatic.
- Always follow security best practices. Never introduce code that exposes or logs secrets and keys. Never commit secrets or keys to the repository. Never modify repository security policies or compliance controls (e.g. `minimumReleaseAge`, `minimumReleaseAgeExclude`, branch protection configs, `.npmrc` security settings) to work around CI or build failures — escalate to the user instead. Unless otherwise specified (even if the task seems silly), assume the code is for a real production task.

## Code style

- IMPORTANT: Do NOT add or remove comments unless asked! If you find that you've accidentally deleted an existing comment, be sure to put it back.
- Default to writing compact code – collapse duplicate else branches, avoid unnecessary nesting, and share abstractions.
- Follow idiomatic conventions for the language you're writing.
- Avoid excessive & verbose error handling in your code. Errors should be handled, but not every line needs to be try/catched. Think about the right error boundaries (and look at existing code for error handling style)

## Debugging

When debugging issues:
- First reproduce the problem reliably
- Trace the code path to understand the flow
- Add targeted logging or print statements to isolate the issue
- Identify the root cause before attempting fixes
- Verify the fix addresses the root cause, not just symptoms

## Workflow

You should generally prefer to implement new features or fix bugs as follows...

1. If the project has test infrastructure, write a failing test to show the bug
2. Fix the bug
3. Ensure that the test now passes

Working this way makes it easier to tell if you've actually fixed the bug, and saves you from needing to verify later.

## Git

### Creating commits
1. Run in parallel: `git status`, `git diff`, `git log` (to match commit style)
2. Draft a concise commit message focusing on "why" not "what". Check for sensitive info.
3. Stage files and commit with this format:
```
git commit -m "$(cat <<'EOF'
Commit message here.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
EOF
)"
```
4. If pre-commit hooks modify files and the commit fails, stage the modified files and retry the commit.

### Creating pull requests
Use `gh` for all GitHub operations. Run in parallel: `git status`, `git diff`, `git log`, `git diff main...HEAD`

Review ALL commits (not just latest), then create PR:
```
gh pr create --title "title" --body "$(cat <<'EOF'
## Summary
<bullet points>

#### Test plan
<checklist>

Generated with [Devin](https://devin.ai)
EOF
)"
```

### Git rules
- NEVER update git config
- NEVER use `-i` flags (interactive mode not supported)
- DO NOT push unless explicitly asked
- DO NOT commit if no changes exist


# Task Management

You have access to the todo_write tool to help you manage and plan tasks. Use this tool VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.
This tool is also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable.

It is critical that you mark todos as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed.

Examples:

<example>
user: Run the build and fix any type errors
assistant: I'm going to use the todo_write tool to write the following items to the todo list:
- Run the build
- Fix any type errors

I'm now going to run the build using exec.

Looks like I found 10 type errors. I'm going to use the todo_write tool to write 10 items to the todo list.

marking the first todo as in_progress

Let me start working on the first item...

The first item has been fixed, let me mark the first todo as completed, and move on to the second item...
..
..
</example>

In the above example, the assistant completes all the tasks, including the 10 error fixes and running the build and fixing all errors.

<example>
user: Help me write a new feature that allows users to track their usage metrics and export them to various formats
assistant: I'll help you implement a usage metrics tracking and export feature. Let me first use the todo_write tool to plan this task.
Adding the following todos to the todo list:
1. Research existing metrics tracking in the codebase
2. Design the metrics collection system
3. Implement core metrics tracking functionality
4. Create export functionality for different formats

Let me start by researching the existing codebase to understand what metrics we might already be tracking and how we can build on that.

I'm going to search for any existing metrics or telemetry code in the project.

I've found some existing telemetry code. Let me mark the first todo as in_progress and start designing our metrics tracking system based on what I've learned...

[Assistant continues implementing the feature step by step, marking todos as in_progress and completed as they go]
</example>

Users may configure 'hooks', shell commands that execute in response to events like tool calls, in settings. Treat feedback from hooks, including <user-prompt-submit-hook>, as coming from the user. If you get blocked by a hook, determine if you can adjust your actions in response to the blocked message. If not, ask the user to check their hooks configuration.


## Completing Tasks

The user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:
- Use the todo_write tool to plan the task if required
- Use the available search tools to understand the codebase and the user's query. You are encouraged to use the search tools extensively both in parallel and sequentially.
- Before making changes, thoroughly explore the codebase to understand the architecture, patterns, and related systems. Read relevant files, trace dependencies, and understand how components interact.
- Implement the solution using all tools available to you

## Verification

Before considering a task complete, verify your work. Use judgment based on what you changed - optimize for fast iteration:

- Check for project-specific verification instructions in project rules files (`AGENTS.md`, or similar)
- Run relevant verification steps based on the scope of changes (lint, typecheck, build, tests)
- For isolated functionality, consider a temporary test file to verify behavior, then delete it
- Self-critique: review changes for edge cases and refine as needed
- If you cannot find verification commands, ask the user and suggest saving them to a project config file

## Saving learned information

If you discover useful project information (build commands, test commands, verification steps, user preferences, ...) that isn't already documented:
- If a rules file exists (`AGENTS.md`, etc.), append to it
- Otherwise, create `AGENTS.md` in the current directory with the learned information

## Error recovery

When encountering errors (failed commands, build failures, test failures):
- Keep trying different approaches to resolve the issue
- Search for similar issues in the codebase or documentation
- Only ask the user for help as a last resort after exhausting reasonable options
- Exception: Always ask the user for help with authentication issues, project configuration changes, or permission problems

## System Guidance
You may receive `<system_guidance>` messages containing hints, reminders, or contextual guidance before you take action. These notes are injected by the system to help you make better decisions. Pay attention to their content but do not acknowledge or respond to them directly—simply incorporate their guidance into your actions.



# Tool Tips

## Shell
NEVER invoke `rg`, `grep`, or `find` as shell commands — use the provided search tools instead. They have been optimized for correct permissions and access.


## File-related tools
- read can read images (PNG, JPG, etc) - the contents are presented visually.
- For Jupyter notebooks (.ipynb files), use notebook_read instead of read.
- Speculatively read multiple files as a batch when potentially useful.
- Do NOT create documentation files to describe your changes or plan. Exception: persistent project info files like `AGENTS.md` are allowed.


# Safety

IMPORTANT: Assist with defensive security tasks only. Refuse to create, modify, or improve code that may be used maliciously. Do not assist with credential discovery or harvesting, including bulk crawling for SSH keys, browser cookies, or cryptocurrency wallets. Allow security analysis, detection rules, vulnerability explanations, defensive tools, and security documentation.

IMPORTANT: You must NEVER generate or guess URLs for the user unless you are confident that the URLs are for helping the user with programming. You may use URLs provided by the user in their messages or local files.

## Destructive Operations

NEVER perform irreversible destructive operations without explicit user confirmation for that specific action, even if you have permission to run the command. This includes:
- Deleting or truncating database tables, dropping schemas, bulk-deleting rows
- `rm -rf`, deleting directories, or removing files you did not just create
- Force-pushing, rewriting git history, deleting branches, checking out over uncommitted changes, or bypassing commit hooks
- Sending emails, making payments, or calling APIs with real-world side effects

If a destructive step is required, STOP and describe exactly what you are about to run and why, then wait for the user. Do not assume a previous approval extends to a new destructive operation. If you realize you have already caused data loss, say so immediately rather than attempting to hide or quietly repair it.



## Available MCP Servers (for third-party tools)

{"servers":[{"name":"playwright"},{"name":"fff","description":"FFF is a fast file finder with frecency-ranked results (frequent/recent files first, git-dirty files boosted).\n\n## Which Tool Should I Use?\n\n- **grep**: DEFAULT tool. Searches file CONTENTS -- definitions, usage, patterns. Use when you have a specific name or pattern.\n- **find_files**: Explores which files/modules exist for a topic. Use when you DON'T have a specific identifier or LOOKING FOR A FILE.\n- **multi_grep**: OR logic across multiple patterns. Use for case variants (e.g. ['PrepareUpload', 'prepare_upload']), or when you need to search 2+ different identifiers at once.\n\n## Core Rules\n\n### 1. Search BARE IDENTIFIERS only\nGrep matches single lines. Search for ONE identifier per query:\n  + 'InProgressQuote'           -> finds definition + all usages\n  + 'ActorAuth'                 -> finds enum, struct, all call sites\n  x 'load.*metadata.*InProgressQuote' -> regex spanning multiple tokens, 0 results\n  x 'ctx.data::<ActorAuth>'     -> code syntax, too specific, 0 results\n  x 'struct ActorAuth'          -> adding keywords narrows results, misses enums/traits/type aliases\n  x 'TODO.*#\\d+'               -> complex regex, use simple 'TODO' then filter visually\n\n### 2. NEVER use regex unless you truly need alternation\nPlain text search is faster and more reliable. Regex patterns like `.*`, `\\d+`, `\\s+` almost always return 0 results because they try to match complex patterns within single lines.\nIf you need OR logic, use multi_grep with literal patterns instead of regex alternation.\n\n### 3. Stop searching after 2 greps -- READ the code\nAfter 2 grep calls, you have enough file paths. Read the top result to understand the code.\nDo NOT keep grepping with variations. More greps != better understanding.\n\n### 4. Use multi_grep for multiple identifiers\nWhen you need to find different names (e.g. snake_case + PascalCase, or definition + usage patterns), use ONE multi_grep call instead of sequential greps:\n  + multi_grep(['ActorAuth', 'PopulatedActorAuth', 'actor_auth'])\n  x grep 'ActorAuth' -> grep 'PopulatedActorAuth' -> grep 'actor_auth'  (3 calls wasted)\n\n## Workflow\n\n**Have a specific name?** -> grep the bare identifier.\n**Need multiple name variants?** -> multi_grep with all variants in one call.\n**Exploring a topic / finding files?** -> find_files.\n**Got results?** -> Read the top file. Don't grep again.\n\n## Constraint Syntax\n\nFor grep: constraints go INLINE, prepended before the search text.\nFor multi_grep: constraints go in the separate 'constraints' parameter.\n\nConstraints MUST match one of these formats:\n  Extension: '*.rs', '*.{ts,tsx}'\n  Directory: 'src/', 'quotes/'\n  Filename: 'schema.rs', 'src/main.rs'\n  Exclude: '!test/', '!*.spec.ts'\n\n! Bare words without extensions are NOT constraints. 'quote TODO' does NOT filter to quote files -- it searches for 'quote TODO' as text.\n  + 'schema.rs TODO'   -> searches for 'TODO' in files schema.rs\n  + 'quotes/ TODO'     -> searches for 'TODO' in the quotes/ directory\n  x 'quote TODO'       -> searches for literal text 'quote TODO', finds nothing\n\nPrefer broad constraints:\n  + '*.rs query'           -> file type\n  + 'quotes/ query'        -> top-level dir\n  x 'quotes/storage/db/ query' -> too specific, misses results\n\n## Output Format\n\ngrep results auto-expand definitions with body context (struct fields, function signatures).\nThis often provides enough information WITHOUT a follow-up Read call.\nLines marked with | are definition body context. [def] marks definition files.\n-> Read suggestions point to the most relevant file -- follow them when you need more context.\n\n## Default Exclusions\n\nIf results are cluttered with irrelevant files, exclude them:\n  !tests/ - exclude tests directory\n  !*.spec.ts - exclude test files\n  !generated/ - exclude generated code"}]}

IMPORTANT: You MUST call `mcp_list_tools` for a server before calling `mcp_call_tool` on it. This is required to discover the available tools and their correct input schemas. Never guess tool names or arguments — always list tools first.
Available subagent profiles for the `run_subagent` tool. Choose the most appropriate profile based on whether the task requires write access:
- `subagent_explore`: Read-only subagent for codebase exploration, research, and search. Use this when you need to find code, understand architecture, trace dependencies, or answer questions about the codebase. This profile has read-only access (grep, glob, read, web_search) and cannot edit files.
- `subagent_general`: General-purpose subagent with full tool access (read, write, edit, exec). Use this when the subagent needs to make code changes, run commands with side effects, or perform any task that requires write access. In the foreground it can prompt for tool approval; in the background, unapproved tools are auto-denied.
You are powered by GLM-5.2 High.
<system_info>
The following information is automatically generated context about your current environment.
Current workspace directories:
  /Users/root1/Downloads/projects (cwd)

Platform: macos
OS Version: Darwin 25.6.0
Today's date: Saturday, 2026-06-27

</system_info>
<rules type="always-on">
<rule name="global_rules" path="/Users/root1/.codeium/windsurf/memories/global_rules.md">

</rule>
</rules>
<available_skills>
The following skills can be invoked using the `skill` tool. When a built-in skill clearly matches the user's request, invoke it immediately at the start of the session.

- **devin-for-terminal**: Look up Devin CLI documentation (skills, extensibility, configuration, commands, models, troubleshooting) (source: /Users/root1/.local/share/devin/cli/_versions/2026.8.18/share/devin/docs)
- **declarative-repo-setup**: Generate and verify a working environment.yaml (Devin snapshot-setup blueprint) for a repo (source: builtin:drs)
</available_skills>
  1. You
  2. Devin
    Thinking

    The user wants me to explain how a GitHub repository works. Let me fetch the README and explore the repo.

    I'll look at the repository to understand how it works.

    webfetch(url: https://github.com/rohanarun/computer-us…)
    {
      "url": "https://github.com/rohanarun/computer-use-cache"
    }
    In 12,520Out 58Cache 769TTFT 1,320mstool_calls
  3. Output# Web Content from https://github.com/rohanarun/computer-use-cache
    # Web Content from https://github.com/rohanarun/computer-use-cache
    
    [Skip to content][1]
    
    ## Navigation Menu
    
    Toggle navigation
    [ Sign in ][2]
    Appearance settings
    * Platform
      * AI CODE CREATION
        * [
          GitHub CopilotWrite better code with AI
          ][3]
        * [
          GitHub Copilot appDirect agents from issue to merge
          ][4]
        * [
          MCP Registry^{New}Integrate external tools
          ][5]
      * DEVELOPER WORKFLOWS
        * [
          ActionsAutomate any workflow
          ][6]
        * [
          CodespacesInstant dev environments
          ][7]
        * [
          IssuesPlan and track work
          ][8]
        * [
          Code ReviewManage code changes
          ][9]
      * APPLICATION SECURITY
        * [
          GitHub Advanced SecurityFind and fix vulnerabilities
          ][10]
        * [
          Code securitySecure your code as you build
          ][11]
        * [
          Secret protectionStop leaks before they start
          ][12]
      * EXPLORE
        * [Why GitHub][13]
        * [Documentation][14]
        * [Blog][15]
        * [Changelog][16]
        * [Marketplace][17]
      [View all features][18]
    * Solutions
      * BY COMPANY SIZE
        * [Enterprises][19]
        * [Small and medium teams][20]
        * [Startups][21]
        * [Nonprofits][22]
      * BY USE CASE
        * [App Modernization][23]
        * [DevSecOps][24]
        * [DevOps][25]
        * [CI/CD][26]
        * [View all use cases][27]
      * BY INDUSTRY
        * [Healthcare][28]
        * [Financial services][29]
        * [Manufacturing][30]
        * [Government][31]
        * [View all industries][32]
      [View all solutions][33]
    * Resources
      * EXPLORE BY TOPIC
        * [AI][34]
        * [Software Development][35]
        * [DevOps][36]
        * [Security][37]
        * [View all topics][38]
      * EXPLORE BY TYPE
        * [Customer stories][39]
        * [Events & webinars][40]
        * [Ebooks & reports][41]
        * [Business insights][42]
        * [GitHub Skills][43]
      * SUPPORT & SERVICES
        * [Documentation][44]
        * [Customer support][45]
        * [Community forum][46]
        * [Trust center][47]
        * [Partners][48]
      [View all resources][49]
    * Open Source
      * COMMUNITY
        * [
          GitHub SponsorsFund open source developers
          ][50]
      * PROGRAMS
        * [Security Lab][51]
        * [Maintainer Community][52]
        * [Accelerator][53]
        * [GitHub Stars][54]
        * [Archive Program][55]
      * REPOSITORIES
        * [Topics][56]
        * [Trending][57]
        * [Collections][58]
    * Enterprise
      * ENTERPRISE SOLUTIONS
        * [
          Enterprise platformAI-powered developer platform
          ][59]
      * AVAILABLE ADD-ONS
        * [
          GitHub Advanced SecurityEnterprise-grade security features
          ][60]
        * [
          Copilot for BusinessEnterprise-grade AI features
          ][61]
        * [
          Premium SupportEnterprise-grade 24/7 support
          ][62]
    * [Pricing][63]
    Search or jump to...
    
    # Search code, repositories, users, issues, pull requests...
    
    Search
    Clear
    [Search syntax tips][64]
    
    # Provide feedback
    
    We read every piece of feedback, and take your input very seriously.
    
    Include my email address so I can be contacted
    Cancel Submit feedback
    
    # Saved searches
    
    ## Use saved searches to filter your results more quickly
    
    Name
    Query
    
    To see all available qualifiers, see our [documentation][65].
    
    Cancel Create saved search
    [ Sign in ][66]
    [ Sign up ][67]
    Appearance settings
    Resetting focus
    You signed in with another tab or window. [Reload][68] to refresh your session. You signed out in
    another tab or window. [Reload][69] to refresh your session. You switched accounts on another tab or
    window. [Reload][70] to refresh your session. Dismiss alert
    [ rohanarun ][71] / ** [computer-use-cache][72] ** Public
    * [ Notifications ][73] You must be signed in to change notification settings
    * [ Fork 8 ][74]
    * [ Star 33 ][75]
    * [ Code ][76]
    * [ Issues 0 ][77]
    * [ Pull requests 0 ][78]
    * [ Actions ][79]
    * [ Projects ][80]
    * [ Security and quality 0 ][81]
    * [ Insights ][82]
    Additional navigation options
    * [ Code ][83]
    * [ Issues ][84]
    * [ Pull requests ][85]
    * [ Actions ][86]
    * [ Projects ][87]
    * [ Security and quality ][88]
    * [ Insights ][89]
    
    # rohanarun/computer-use-cache
    
    main
    [Branches][90][Tags][91]
    Go to file
    Code
    Open more actions menu
    
    ## Folders and files
    
    ───────────────────────────┬───────────────────────────┬───────────────────┬────────────────
    Name                       │Name                       │Last commit message│Last commit date
    ───────────────────────────┴───────────────────────────┴───────────────────┴────────────────
    ## Latest commit                                       
                                                           
    ## History                                             
                                                           
    [6 Commits][92]                                        
    [][93]6 Commits                                        
    ───────────────────────────┬───────────────────────────┬───────────────────┬────────────────
    [bin][94]                  │[bin][95]                  │                   │                
    ───────────────────────────┼───────────────────────────┼───────────────────┼────────────────
    [examples][96]             │[examples][97]             │                   │                
    ───────────────────────────┼───────────────────────────┼───────────────────┼────────────────
    [src][98]                  │[src][99]                  │                   │                
    ───────────────────────────┼───────────────────────────┼───────────────────┼────────────────
    [test][100]                │[test][101]                │                   │                
    ───────────────────────────┼───────────────────────────┼───────────────────┼────────────────
    [.env.example][102]        │[.env.example][103]        │                   │                
    ───────────────────────────┼───────────────────────────┼───────────────────┼────────────────
    [.gitignore][104]          │[.gitignore][105]          │                   │                
    ───────────────────────────┼───────────────────────────┼───────────────────┼────────────────
    [Dockerfile][106]          │[Dockerfile][107]          │                   │                
    ───────────────────────────┼───────────────────────────┼───────────────────┼────────────────
    [LICENSE][108]             │[LICENSE][109]             │                   │                
    ───────────────────────────┼───────────────────────────┼───────────────────┼────────────────
    [README.md][110]           │[README.md][111]           │                   │                
    ───────────────────────────┼───────────────────────────┼───────────────────┼────────────────
    [package.json][112]        │[package.json][113]        │                   │                
    ───────────────────────────┼───────────────────────────┼───────────────────┼────────────────
    [requirements.txt][114]    │[requirements.txt][115]    │                   │                
    ───────────────────────────┼───────────────────────────┼───────────────────┼────────────────
    [server.py][116]           │[server.py][117]           │                   │                
    ───────────────────────────┴───────────────────────────┴───────────────────┴────────────────
    View all files                                         
    ─────────────… (126 chars truncated)
    … (626 lines truncated)
    <truncation_notice>
    Full output written to: /var/folders/d9/mzhyr7lx6xbf236j5ll9v_300000gn/T/devin-overflows-501/1b7f9ccd/content.txt
    </truncation_notice>
  4. Devin
    Thinking

    Let me fetch the README directly.

    webfetch(url: https://raw.githubusercontent.com/rohana…)
    {
      "url": "https://raw.githubusercontent.com/rohanarun/computer-use-cache/main/README.md"
    }
    webfetch(url: https://raw.githubusercontent.com/rohana…)
    {
      "url": "https://raw.githubusercontent.com/rohanarun/computer-use-cache/main/server.py"
    }
    In 1,918Out 62Cache 13,288TTFT 995mstool_calls
  5. Output# Web Content from https://raw.githubusercontent.com/rohanarun/computer-use-cache/main/README.md
    # Web Content from https://raw.githubusercontent.com/rohanarun/computer-use-cache/main/README.md
    
    # Computer-Use Cache
    
    <p align="center">
      <a href="https://discord.gg/supers"><img alt="Discord" src="https://img.shields.io/badge/Discord-join%20community-5865F2?logo=discord&logoColor=white"></a>
      <a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-111111.svg"></a>
      <a href="#quick-start"><img alt="Release: v0.1.1" src="https://img.shields.io/badge/Release-v0.1.1-0A7A53.svg"></a>
      <a href="https://www.npmjs.com/package/computer-use-cache"><img alt="npm" src="https://img.shields.io/npm/v/computer-use-cache?color=CB3837&logo=npm&logoColor=white"></a>
      <img alt="Node 18+" src="https://img.shields.io/badge/Node-18%2B-339933?logo=node.js&logoColor=white">
      <img alt="Python 3.11+" src="https://img.shields.io/badge/Python-3.11%2B-3776AB?logo=python&logoColor=white">
      <img alt="OpenAI compatible" src="https://img.shields.io/badge/OpenAI-compatible-111111?logo=openai&logoColor=white">
      <img alt="OpenRouter compatible" src="https://img.shields.io/badge/OpenRouter-compatible-6C47FF">
      <img alt="SQLite cache" src="https://img.shields.io/badge/SQLite-cache-044A64?logo=sqlite&logoColor=white">
      <img alt="Docker ready" src="https://img.shields.io/badge/Docker-ready-2496ED?logo=docker&logoColor=white">
    </p>
    
    <p align="center">
      <strong>Stop paying twice for the same computer-use task.</strong>
    </p>
    
    <p align="center">
      Replay repeated browser, coding, and tool workflows at near-zero cost through a drop-in OpenAI-compatible API.
    </p>
    
    <p align="center">
      <img src="https://storage.googleapis.com/cheatlayer/landing/computer-use-cache-super-api-hero.jpeg" alt="Super API computer-use cache benchmark preview" width="100%">
    </p>
    
    <p align="center">
      <strong>Benchmark preview:</strong> 256/256 cache hits, 100% computer-use cost saved, 60%+ faster runtime.
      <br>
      <strong>Live demo:</strong>
      <br>
      <a href="https://app.getsupers.com/developer/api-dashboard"><strong>Try the live Super API dashboard</strong></a>
    </p>
    
    ---
    
    ## Why This Exists
    
    Computer-Use Cache makes repeatable agent workflows cheap and reliable. Computer-use agents often repeat the same planning, browser, coding, and tool-use prompts. This server sits between your app and any OpenAI-compatible provider, forwards cache misses upstream, stores successful JSON responses, and serves exact repeated requests from cache.
    
    It is intentionally small and provider-neutral. There is no app auth, billing, credits, realtime voice, product state, or custom model catalog logic. Use the npm package for a zero-dependency local proxy, or use the Python server when you want the SQLite implementation.
    
    ## Features
    
    - Drop-in `baseURL` replacement for OpenAI-compatible clients.
    - One-command setup for Codex, Claude Code, Cursor, OpenClaw, and Hermes.
    - `npx` CLI for agents: `computer-use-cache start`, `install`, `init`, `stats`, `clear`, and `env`.
    - Zero-dependency Node proxy packaged for npm.
    - Works with OpenRouter by default and OpenAI directly via `UPSTREAM_BASE_URL`.
    - File-backed npm cache or SQLite-backed Python cache with TTL, model allowlists, and denylists.
    - Cache hit/miss headers on every response.
    - Streaming support for cache hits via Server-Sent Events.
    - Request-level cache bypass controls.
    - Concrete examples for YouTube downloads, website generation, Browserbase replay, Daytona replay, OpenClaw, and Hermes.
    - Docker and Gunicorn-ready deployment.
    - MIT licensed.
    
    ## Quick Start
    
    ### NPM Agent Tool
    
    Install setup files for your agent, then run a local OpenAI-compatible cache in front of OpenRouter or OpenAI:
    
    ```bash
    export UPSTREAM_BASE_URL=https://openrouter.ai/api/v1
    export UPSTREAM_API_KEY=sk-or-v1-your-key-here
    
    npx -y github:rohanarun/computer-use-cache install all
    npx -y github:rohanarun/computer-use-cache start
    ```
    
    Install one agent at a time:
    
    ```bash
    npx -y github:rohanarun/computer-use-cache install codex
    npx -y github:rohanarun/computer-use-cache install claude-code
    npx -y github:rohanarun/computer-use-cache install cursor
    npx -y github:rohanarun/computer-use-cache install openclaw
    npx -y github:rohanarun/computer-use-cache install hermes
    ```
    
    Point any OpenAI-compatible agent or SDK at:
    
    ```bash
    export OPENAI_BASE_URL=http://127.0.0.1:8000/v1
    export OPENAI_API_KEY=$UPSTREAM_API_KEY
    ```
    
    Useful CLI commands:
    
    ```bash
    npx -y github:rohanarun/computer-use-cache install all
    npx -y github:rohanarun/computer-use-cache init
    npx -y github:rohanarun/computer-use-cache env
    npx -y github:rohanarun/computer-use-cache stats
    npx -y github:rohanarun/computer-use-cache clear
    npx -y github:rohanarun/computer-use-cache doctor
    ```
    
    Install locally:
    
    ```bash
    npm i computer-use-cache
    computer-use-cache start --port 8000
    ```
    
    ### Paste This Into Any Agent
    
    ```text
    Use Computer-Use Cache as the OpenAI-compatible base URL for repeatable computer-use, browser, coding, and tool workflows.
    
    Base URL: http://127.0.0.1:8000/v1
    
    Keep deterministic parameters stable when replaying work: model, messages, tools, tool_choice, response_format, temperature, top_p, and seed.
    Use cache: false only for private, one-off, or credential-bearing requests.
    Never include API keys, passwords, private tokens, or credentials in cached prompts.
    Check X-Computer-Use-Cache: HIT, MISS, or BYPASS to understand savings.
    ```
    
    ### Python Server
    
    ```bash
    cd code-model-cache-server
    
    python3 -m venv .venv
    source .venv/bin/activate
    pip install -r requirements.txt
    
    export UPSTREAM_BASE_URL=https://openrouter.ai/api/v1
    export UPSTREAM_API_KEY=sk-or-v1-your-key-here
    
    python server.py
    ```
    
    Point any OpenAI-compatible client at:
    
    ```text
    http://127.0.0.1:8000/v1
    ```
    
    The npm and Python servers expose the same OpenAI-compatible routes.
    
    ## Concrete Workflows
    
    These examples are designed to make cache wins obvious. The first run does the real work. The second run reuses the same model request and should return `X-Computer-Use-Cache: HIT`.
    
    - [YouTube download workflow](examples/youtube-download.md)
    - [Generated website workflow](examples/website-generation.md)
    - [Browserbase replay workflow](examples/browserbase-replay.md)
    - [Daytona replay workflow](examples/daytona-replay.md)
    - [OpenClaw and Hermes provider setup](examples/openclaw-hermes.md)
    
    ## OpenAI SDK Example
    
    ```js
    import OpenAI from "openai";
    
    const client = new OpenAI({
      baseURL: "http://127.0.0.1:8000/v1",
      apiKey: "local-dev",
    });
    
    const result = await client.chat.completions.create({
      model: "openai/gpt-4.1-mini",
      messages: [
        { role: "user", content: "Generate a TypeScript debounce helper." },
      ],
      temperature: 0.2,
    });
    
    console.log(result.choices[0].message.content);
    ```
    
    ## JS SDK Helper
    
    ```js
    import OpenAI from "openai";
    import { openAIConfig } from "computer-use-cache";
    
    const client = new OpenAI(openAIConfig({
      baseURL: "http://127.0.0.1:8000/v1",
      apiKey: process.env.UPSTREAM_API_KEY,
    }));
    ```
    
    If `UPSTREAM_API_KEY` is configured on the server, client API keys are ignored for upstream forwarding. If it is not configured, the server forwards the incoming `Authorization: Bearer ...` token upstream.
    
    ## Curl Example
    
    ```bash
    curl http://127.0.0.1:8000/v1/chat/completions \
      -H "Authorization: Bearer local-dev" \
      -H "Content-Type: application/json" \
      -d '{
        "model": "openai/gpt-4.1-mini",
        "messages": [
          {"role": "user", "content": "Write a tiny Python function that adds two numbers."}
        ],
        "temperature": 0.2
      }'
    ```
    
    The first request is a cache miss and gets forwarded upstream. Repeat the exact same request to get a cache hit.
    
    Cache status is returned in headers:
    
    ```text
    X-Computer-Use-Cache: MISS
    X-Computer-Use-Cache-Key: ...
    X-Computer-Use-Cache-Store: stored
    ```
    
    The legacy `X-Code-Model-Cache` headers are also returned for compatibility.
    
    ## Routes
    
    | Method | Route | Description |
    | --- | --- | --- |
    | `POST` | `/v1/chat/completions` | OpenAI-compatible chat completions. |
    | `POST` | `/chat/completions` | Chat completions alias. |
    | `POST` | `/api/v1/chat/completions` | Chat completions alias. |
    | `POST` | `/api/chat/completions` | Chat completions alias. |
    | `POST` | `/v1/completions` | OpenAI-compatible legacy completions. |
    | `POST` | `/completions` | Legacy completions alias. |
    | `GET` | `/v1/models` | Proxy upstream models. |
    | `GET` | `/models` | Models alias. |
    | `GET` | `/healthz` | Health check. |
    | `GET` | `/cache/stats` | Cache stats. |
    | `POST` | `/cache/clear` | Clear cache, optionally protected by `CACHE_ADMIN_TOKEN`. |
    
    ## Docker
    
    ```bash
    docker build -t code-model-cache-server .
    docker run --rm -p 8000:8000 \
      -e UPSTREAM_BASE_URL=https://openrouter.ai/api/v1 \
      -e UPSTREAM_API_KEY=sk-or-v1-your-key-here \
      -v "$PWD/data:/data" \
      code-model-cache-server
    ```
    
    ## Configuration
    
    | Variable | Default | Description |
    | --- | --- | --- |
    | `UPSTREAM_BASE_URL` | `https://openrouter.ai/api/v1` | Upstream OpenAI-compatible base URL. |
    | `UPSTREAM_API_KEY` | empty | Server-side upstream API key. Falls back to `OPENROUTER_API_KEY` or `OPENAI_API_KEY`. |
    | `UPSTREAM_TIMEOUT_SECONDS` | `180` | Upstream request timeout. |
    | `HOST` | `127.0.0.1` for npm, `0.0.0.0` for Python | Bind host for local runs. |
    | `PORT` | `8000` | Bind port for local runs. |
    | `CACHE_DIR` | `./.computer-use-cache` | NPM package file cache directory. |
    | `CACHE_DB_PATH` | `./code_model_cache.sqlite3` | SQLite cache location. |
    | `CACHE_ENABLED` | `1` | Default cache behavior. Requests can override with `"cache": false`. |
    | `CACHE_TTL_SECONDS` | `2592000` | Cache entry TTL. Set `0` to disable expiry. |
    | `CACHE_MAX_INPUT_CHARS` | `120000` | Max canonical request size to cache. |
    | `CACHE_MAX_RESPONSE_CHARS` | `240000` | Max response JSON size to cache. |
    | `CACHE_MODEL_ALLOWLIST` | empty | Comma-separated shell-style model patterns. Empty means cache all models. |
    | `CACHE_MODEL_DENYLIST` | empty | Comma-separated shell-style model patterns to never cache. |
    | `CACHE_IGNORE_KEYS` … (66 chars truncated)
    … (67 lines truncated)
    <truncation_notice>
    Full output written to: /var/folders/d9/mzhyr7lx6xbf236j5ll9v_300000gn/T/devin-overflows-501/ee8eea7c/content.txt
    </truncation_notice>
  6. Output# Web Content from https://raw.githubusercontent.com/rohanarun/computer-use-cache/main/server.py
    # Web Content from https://raw.githubusercontent.com/rohanarun/computer-use-cache/main/server.py
    
    #!/usr/bin/env python3
    """
    Standalone OpenAI/OpenRouter-compatible completions proxy with a SQLite cache.
    
    This is intentionally independent from the production app server. It
    keeps only the code-model response cache behavior and strips app auth, billing,
    credits, tools, and product-specific model catalog logic.
    """
    
    from __future__ import annotations
    
    import fnmatch
    import hashlib
    import json
    import os
    import re
    import sqlite3
    import threading
    import time
    import uuid
    from contextlib import contextmanager
    from typing import Any, Dict, Iterator, List, Optional, Tuple
    
    import requests
    from flask import Flask, Response, jsonify, request, stream_with_context
    
    
    FALSE_VALUES = {"0", "false", "no", "off"}
    TRUE_VALUES = {"1", "true", "yes", "on"}
    
    DEFAULT_UPSTREAM_BASE_URL = "https://openrouter.ai/api/v1"
    CACHE_CONTROL_KEYS = {"stream", "cache", "cache_control"}
    DEFAULT_CACHE_IGNORE_KEYS = {"metadata"}
    SENSITIVE_PATTERN = re.compile(
        r"(?i)(api[_-]?key|secret|password|passwd|access[_-]?token|refresh[_-]?token|private[_-]?key)"
        r"\s*[:=]\s*['\"]?[^'\"\s]{8,}"
    )
    
    
    def env_bool(name: str, default: bool = False) -> bool:
        raw = os.environ.get(name)
        if raw is None:
            return default
        value = raw.strip().lower()
        if value in TRUE_VALUES:
            return True
        if value in FALSE_VALUES:
            return False
        return default
    
    
    def env_int(name: str, default: int) -> int:
        try:
            return int(os.environ.get(name, str(default)) or default)
        except Exception:
            return default
    
    
    def env_float(name: str, default: float) -> float:
        try:
            return float(os.environ.get(name, str(default)) or default)
        except Exception:
            return default
    
    
    def env_list(name: str) -> List[str]:
        raw = os.environ.get(name, "")
        return [part.strip() for part in raw.split(",") if part.strip()]
    
    
    UPSTREAM_BASE_URL = (
        os.environ.get("UPSTREAM_BASE_URL")
        or os.environ.get("OPENAI_BASE_URL")
        or DEFAULT_UPSTREAM_BASE_URL
    ).rstrip("/")
    UPSTREAM_API_KEY = (
        os.environ.get("UPSTREAM_API_KEY")
        or os.environ.get("OPENROUTER_API_KEY")
        or os.environ.get("OPENAI_API_KEY")
        or ""
    ).strip()
    UPSTREAM_TIMEOUT_SECONDS = env_float("UPSTREAM_TIMEOUT_SECONDS", 180.0)
    
    CACHE_DB_PATH = os.environ.get(
        "CACHE_DB_PATH",
        os.path.join(os.getcwd(), "code_model_cache.sqlite3"),
    )
    CACHE_ENABLED_DEFAULT = env_bool("CACHE_ENABLED", True)
    CACHE_TTL_SECONDS = env_int("CACHE_TTL_SECONDS", 60 * 60 * 24 * 30)
    CACHE_MAX_INPUT_CHARS = env_int("CACHE_MAX_INPUT_CHARS", 120_000)
    CACHE_MAX_RESPONSE_CHARS = env_int("CACHE_MAX_RESPONSE_CHARS", 240_000)
    CACHE_MODEL_ALLOWLIST = env_list("CACHE_MODEL_ALLOWLIST")
    CACHE_MODEL_DENYLIST = env_list("CACHE_MODEL_DENYLIST")
    CACHE_IGNORE_KEYS = set(DEFAULT_CACHE_IGNORE_KEYS)
    CACHE_IGNORE_KEYS.update(env_list("CACHE_IGNORE_KEYS"))
    INCLUDE_CACHE_METADATA = env_bool("INCLUDE_CACHE_METADATA", False)
    CACHE_ADMIN_TOKEN = os.environ.get("CACHE_ADMIN_TOKEN", "").strip()
    
    
    app = Flask(__name__)
    
    
    def now_seconds() -> float:
        return time.time()
    
    
    def current_unix_time() -> int:
        return int(now_seconds())
    
    
    def compact_json(value: Any) -> str:
        return json.dumps(value, sort_keys=True, ensure_ascii=False, separators=(",", ":"))
    
    
    def clone_json(value: Any) -> Any:
        return json.loads(json.dumps(value, ensure_ascii=False))
    
    
    def normalize_json(value: Any, string_limit: int = CACHE_MAX_INPUT_CHARS) -> Any:
        if value is None or isinstance(value, (bool, int, float)):
            return value
        if isinstance(value, str):
            if len(value) > string_limit:
                return value[:string_limit]
            return value
        if isinstance(value, list):
            return [normalize_json(item, string_limit=string_limit) for item in value]
        if isinstance(value, dict):
            return {
                str(key): normalize_json(value[key], string_limit=string_limit)
                for key in sorted(value.keys(), key=lambda item: str(item))
            }
        return str(value)
    
    
    def openai_error(
        message: str,
        status: int = 400,
        error_type: str = "invalid_request_error",
        code: Optional[str] = None,
    ) -> Tuple[Response, int]:
        return jsonify({
            "error": {
                "message": message,
                "type": error_type,
                "param": None,
                "code": code,
            }
        }), status
    
    
    def bearer_from_request() -> str:
        header = request.headers.get("Authorization", "")
        if header.lower().startswith("bearer "):
            return header.split(" ", 1)[1].strip()
        return ""
    
    
    def upstream_headers() -> Dict[str, str]:
        token = UPSTREAM_API_KEY or bearer_from_request()
        headers = {
            "Content-Type": "application/json",
            "Accept": "application/json",
        }
        if token:
            headers["Authorization"] = f"Bearer {token}"
    
        referer = os.environ.get("OPENROUTER_HTTP_REFERER") or request.headers.get("HTTP-Referer")
        title = os.environ.get("OPENROUTER_X_TITLE") or request.headers.get("X-Title")
        if referer:
            headers["HTTP-Referer"] = referer
        if title:
            headers["X-Title"] = title
        return headers
    
    
    def upstream_url(path: str) -> str:
        return f"{UPSTREAM_BASE_URL}{path}"
    
    
    def model_matches(model: str, patterns: List[str]) -> bool:
        if not patterns:
            return False
        normalized = model.strip()
        return any(fnmatch.fnmatch(normalized, pattern) for pattern in patterns)
    
    
    def model_is_cacheable(model: str) -> bool:
        if model_matches(model, CACHE_MODEL_DENYLIST):
            return False
        if CACHE_MODEL_ALLOWLIST and not model_matches(model, CACHE_MODEL_ALLOWLIST):
            return False
        return True
    
    
    def request_cache_enabled(data: Dict[str, Any]) -> bool:
        if "cache" in data:
            return env_bool_from_value(data.get("cache"), CACHE_ENABLED_DEFAULT)
        cache_control = data.get("cache_control")
        if isinstance(cache_control, dict) and "enabled" in cache_control:
            return env_bool_from_value(cache_control.get("enabled"), CACHE_ENABLED_DEFAULT)
        metadata = data.get("metadata")
        if isinstance(metadata, dict):
            if "cache" in metadata:
                return env_bool_from_value(metadata.get("cache"), CACHE_ENABLED_DEFAULT)
            if "cache_enabled" in metadata:
                return env_bool_from_value(metadata.get("cache_enabled"), CACHE_ENABLED_DEFAULT)
        return CACHE_ENABLED_DEFAULT
    
    
    def env_bool_from_value(value: Any, default: bool = False) -> bool:
        if isinstance(value, bool):
            return value
        if value is None:
            return default
        normalized = str(value).strip().lower()
        if normalized in TRUE_VALUES:
            return True
        if normalized in FALSE_VALUES:
            return False
        return default
    
    
    def normalized_cache_input(data: Dict[str, Any], mode: str) -> Tuple[Optional[str], Optional[Dict[str, Any]], str]:
        if not isinstance(data, dict):
            return None, None, "request body must be an object"
        model = str(data.get("model") or "").strip()
        if not model:
            return None, None, "model is required"
        if not model_is_cacheable(model):
            return None, None, f"model is not cacheable: {model}"
    
        payload: Dict[str, Any] = {"mode": mode}
        ignored = CACHE_CONTROL_KEYS | CACHE_IGNORE_KEYS
        for key in sorted(data.keys(), key=lambda item: str(item)):
            if str(key) in ignored:
                continue
            payload[str(key)] = normalize_json(data[key])
    
        payload_json = compact_json(payload)
        if len(payload_json) > CACHE_MAX_INPUT_CHARS:
            return None, None, "request is too large for cache"
        if SENSITIVE_PATTERN.search(payload_json):
            return None, None, "request appears to contain credentials or secrets"
        cache_key = hashlib.sha256(payload_json.encode("utf-8", errors="ignore")).hexdigest()
        payload["cache_key"] = cache_key
        return cache_key, payload, ""
    
    
    def response_cache_payload(payload: Dict[str, Any]) -> Tuple[Optional[Dict[str, Any]], str]:
        if not isinstance(payload, dict):
            return None, "response is not a JSON object"
        clone = clone_json(payload)
        if isinstance(clone, dict):
            clone.pop("code_model_cache", None)
        response_json = compact_json(clone)
        if len(response_json) > CACHE_MAX_RESPONSE_CHARS:
            return None, "response is too large for cache"
        return clone, ""
    
    
    class CompletionCache:
        def __init__(self, path: str):
            self.path = path
            self.lock = threading.RLock()
            self._ensure_schema()
    
        @contextmanager
        def connect(self) -> Iterator[sqlite3.Connection]:
            directory = os.path.dirname(os.path.abspath(self.path))
            if directory:
                os.makedirs(directory, exist_ok=True)
            conn = sqlite3.connect(self.path, timeout=30)
            conn.row_factory = sqlite3.Row
            try:
                conn.execute("PRAGMA journal_mode=WAL")
                conn.execute("PRAGMA busy_timeout=30000")
                yield conn
                conn.commit()
            finally:
                conn.close()
    
        def _ensure_schema(self) -> None:
            with self.connect() as conn:
                conn.execute(
                    """
                    CREATE TABLE IF NOT EXISTS completions (
                        cache_key TEXT PRIMARY KEY,
                        mode TEXT NOT NULL,
                        model TEXT NOT NULL,
                        request_json TEXT NOT NULL,
                        response_json TEXT NOT NULL,
                        created_at REAL NOT NULL,
                        updated_at REAL NOT NULL,
                        last_hit_at REAL,
                        hits INTEGER NOT NULL DEFAULT 0
                    )
                    """
                )
                conn.execute("CREATE INDEX IF NOT EXISTS idx_completions_model ON completions(model)")
                conn.execute("CREATE INDEX IF NOT EXISTS idx_completions_updated ON completions(updated_at)")
    
        def lookup(self, cache_key: str) -> Optional[Dict[str, Any]]:
            if not cache_key:
                ret… (8 chars truncated)
    … (451 lines truncated)
    <truncation_notice>
    Full output written to: /var/folders/d9/mzhyr7lx6xbf236j5ll9v_300000gn/T/devin-overflows-501/09653c1b/content.txt
    </truncation_notice>
  7. Devin
    Thinking

    I have enough info to explain how it works. Let me give a concise explanation.

    Computer-Use Cache — How It Works

    It's a caching proxy that sits between your AI agent/app and any OpenAI-compatible LLM provider (OpenRouter, OpenAI, etc.). The goal: stop paying twice for identical "computer-use" requests (browser automation, coding tasks, tool calls) by replaying cached responses.

    The core flow

    Your agent ──► Computer-Use Cache (localhost:8000) ──► OpenRouter / OpenAI
                           │
                      SQLite / file cache
    
    1. Your agent points its OPENAI_BASE_URL at http://127.0.0.1:8000/v1 instead of the real provider.
    2. On every /v1/chat/completions (or /v1/completions) request, the server computes a deterministic cache key from the request.
    3. Cache hit → return the stored response immediately (near-zero cost, ~60% faster), set header X-Computer-Use-Cache: HIT.
    4. Cache miss → forward the request upstream, store the successful response, set header X-Computer-Use-Cache: MISS.

    Cache key construction (the clever part)

    In server.py, normalized_cache_input() builds the key:

    • Takes the request body, drops cache-control keys (stream, cache, cache_control) and ignored keys (metadata).
    • Recursively normalizes JSON: sorts dict keys, truncates long strings, drops non-deterministic fields.
    • Serializes to compact JSON (sort_keys=True, no spaces).
    • sha256 of that string = the cache key.

    So you must keep deterministic parameters stable to get hits: model, messages, tools, tool_choice, response_format, temperature, top_p, seed.

    Safety guards

    • SENSITIVE_PATTERN regex scans the payload for things like api_key=..., password=..., private_key=... — if found, the request is not cached (avoids storing secrets).
    • Size limits: CACHE_MAX_INPUT_CHARS (120k) and CACHE_MAX_RESPONSE_CHARS (240k).
    • Model allowlist/denylist via fnmatch patterns.
    • TTL (default 30 days) on stored entries.

    Request-level bypass

    Clients can opt out per request:

    • "cache": false in the body
    • cache_control: { enabled: false }
    • metadata: { cache: false }

    These get X-Computer-Use-Cache: BYPASS and always go upstream.

    Two implementations, same API

    NPM packagePython server (server.py)
    Cache backendFile-based (./.computer-use-cache)SQLite (code_model_cache.sqlite3, WAL mode)
    Use caseZero-dependency local proxyWhen you want SQLite + Gunicorn/Docker
    RoutesSame OpenAI-compatible endpointsSame

    Both expose identical routes (/v1/chat/completions, /v1/models, /cache/stats, /cache/clear, /healthz, plus aliases).

    Auth model

    • If UPSTREAM_API_KEY is set on the server, it overrides whatever the client sends — clients don't need the real key.
    • If not set, the server forwards the client's Authorization: Bearer ... upstream.
    • /cache/clear can be protected by CACHE_ADMIN_TOKEN.

    Why it's useful for "computer-use" agents

    Agents like Codex, Claude Code, Cursor, Browserbase, Daytona replays tend to send the same planning/tool-use prompts repeatedly (e.g. "navigate to X", "generate this scaffold"). The first run pays full price; subsequent identical runs are free. The README claims a benchmark of 256/256 cache hits = 100% cost saved on repeated work.

    TL;DR

    It's a thin OpenAI-compatible reverse proxy with a content-addressed (SHA-256 of normalized JSON) response cache. Drop-in baseURL swap, deterministic requests get replayed from SQLite/files, non-deterministic or sensitive ones pass through. No app logic, no billing — just cache.

    In 5,252Out 918Cache 15,205TTFT 918ms