Diagnosed a month-old open community regression — Claude Cowork's lost 1M-token context — and resolved it in 48 hours with a local macOS patch
two same-length JS byte swaps • re-signed bundle • fully reversible
Not affiliated with or endorsed by Anthropic. "Claude" is a trademark of Anthropic; used here in nominative reference only.
What this is. A research artifact and a defensive resource for users impacted by anthropics/claude-code#37413, a Cowork-only 1M-context regression that has been open and unaddressed by Anthropic for over a month at the time of writing. The script demonstrates a same-length byte-swap technique on the user's locally-installed copy of Claude Desktop. It does not redistribute Anthropic's source. It does not call Anthropic's servers beyond the normal API your subscription already authorizes. Verified working against Claude Desktop v1.5354.0 on 2026-04-29 — see docs/verification/v1.5354.0.md.
Caution
Auto-updates are disabled after patching. Re-signing the app bundle invalidates the original code signature, which stops Claude Desktop's built-in auto-updater from running. To update Claude Desktop, download a fresh installer from https://claude.ai/download, install it (this overwrites the patched version while preserving your data, sessions, and settings), then re-run ./patch-claude-1m.sh on the new version. A solution to restore automatic updates is in progress.
- Before You Run
- Run the Patch
- Relaunch Claude
- First Launch After Patching
- Verify Success
- Rollback / Troubleshooting
- The Problem
- Scope
- Compatibility
- Inspect before running
- Root Cause · How It Works · Log Evidence
- Caveats
- Further Reading
- Related Issues
- Legal
Prerequisites: macOS, Node.js, Python 3, Claude Desktop installed. The script auto-installs @electron/asar to a temp directory if needed.
Complete these steps before running the patch script:
-
Enable Full Disk Access for your terminal app. Go to
System Settings > Privacy & Security > Full Disk Accessand toggle on the terminal app that will actually launch your shell (Terminal,iTerm2,Ghostty,Warp, etc.). Without this, the script can't read or modify files inside/Applications/Claude.app. -
Be prepared to authorize app modification. When the script touches
/Applications/Claude.app, macOS may show a password prompt or a system dialog asking permission to alter an installed application. Enter your macOS password (admin or current user, depending on your system configuration). If your account is not an administrator, an admin will need to authorize the action - or run the script from an admin account. -
Quit Claude Desktop if it's currently running:
osascript -e 'quit app "Claude"'
Note
The permission prompts above are macOS treating script-driven app modification the same as any other app install or modification - it'll ask you to confirm. If you see a "permission denied" error instead of a password prompt, you almost certainly skipped step 1.
If you want to audit what the script touches before you run it, jump to Inspect before running.
./patch-claude-1m.shThe script handles everything: backs up the original asar, patches the feature flag, updates all integrity hashes, and re-signs the app with preserved entitlements.
After the patch finishes, relaunch Claude Desktop with the command below:
osascript -e 'quit app "Claude"'; sleep 3; open -a ClaudeYou can still reopen Claude manually, but treat that as a fallback. It usually works, but the first manual reopen after patching can rarely stutter, freeze, or crash. If that happens, quit Claude and use the command above.
After patching, the app's code signature changes. The first time you open Claude Desktop - whether via the relaunch command above or by clicking the app icon - macOS will prompt you for your login password to authorize the re-signed app to access keychain entries it had previously stored. You may see several consecutive prompts for different keychain entries.
Important
Click "Always Allow" on each prompt - not just "Allow". "Allow" grants one-time access; "Always Allow" updates the keychain ACL to trust the new signature, so you won't see the prompt on every subsequent launch.
The prompts won't recur until you re-run the patch (which generates a new signature - typically after a manual Claude Desktop update).
A successful run prints:
Layer 1a (feature flag): BYPASSED
Layer 1b (model allow-list): BROADENED
Virtualization entitlement: PRESENT
Then start a new Cowork session and confirm [1m] is being passed to the spawned model:
tail -f ~/Library/Logs/Claude/cowork_vm_node.log | grep -- '--model'You should see --model claude-opus-4-7[1m] (or claude-opus-4-6[1m]).
Restore from the backup the script created on your Desktop:
cp ~/Desktop/app.asar.backup-YYYYMMDD-HHMMSS \
/Applications/Claude.app/Contents/Resources/app.asar
cp ~/Desktop/Info.plist.backup-YYYYMMDD-HHMMSS \
/Applications/Claude.app/Contents/Info.plist
osascript -e 'quit app "Claude"'; sleep 3; open -a Claude- If Claude stuttered, froze, or crashed after a manual reopen, quit it and use the recommended relaunch command.
- To update Claude Desktop after patching, see the auto-update notice at the top of this README - the manual download path also doubles as recovery if patching corrupts something the backup can't fix.
- If preflight exits
unknown, open an issue with your Claude Desktop version and the full script output.
Feature flag 3885610113 controls whether the Cowork model resolution function appends [1m] to model names. On 2026-03-19, the flag was rolled back server-side - same app version, same session setup, different behavior. Log timestamps confirm the boundary: 18:36 [1m], 19:59 no [1m]. The CLI was unaffected; only Desktop's LocalAgentModeSessionManager was broken.
17+ users reported it across GitHub issues #37413, #36760, #36351, #36649, and #33154 with no resolution after over a month. Max subscribers ($200/month) were paying for 1M and getting 200K.
This script is intentionally narrow.
Modifies, locally only:
/Applications/Claude.app/Contents/Resources/app.asar- two same-length JS byte swaps/Applications/Claude.app/Contents/Info.plist- recomputed asar header hash
Reads:
- The local app bundle and its current code-signing entitlements
Network:
- Installs
@electron/asar@4.2.0from npm into a temp dir if not already present (with--ignore-scripts). Preinstall it to skip this step. - No calls to Anthropic APIs.
Backups (created before any mutation):
~/Desktop/app.asar.backup-YYYYMMDD-HHMMSS~/Desktop/Info.plist.backup-YYYYMMDD-HHMMSS
Note
Fails closed: if the script can't recognize the asar shape, it exits with unknown rather than half-patch. No sudo required.
| Claude Desktop version | Layer 1b form | Status | Last tested |
|---|---|---|---|
| 1.569.0 | regex | works | 2026-04-18 |
| 1.3109.0 | array | works | 2026-04-20 |
| 1.5354.0 | array | works | 2026-04-29 (evidence) |
Versions in between are likely fine but haven't been verified. If the byte anchors don't match either form, preflight exits unknown instead of guessing - see CHANGELOG.md for what changed when.
Note
HostLoop status. Some Claude Desktop builds expose a separate execution path called HostLoop that bypasses the function this patch modifies. As of 2026-04-29, HostLoop is server-default-OFF on macOS and the patch works on its own. If you ever observe a successful patch but still capped at 200K, see docs/hostloop-status.md for the manual config-file kill-switch.
Audit what the script touches and what network it uses:
grep -nE 'npm|curl|wget|ssh|scp|rsync' patch-claude-1m.sh
grep -nE '/Applications/Claude.app|Info.plist|app.asar' patch-claude-1m.sh
bash -n patch-claude-1m.shTo skip the npm install entirely, preinstall the pinned dependency yourself:
npm install -g @electron/asar@4.2.0Tip
If macOS rejects the rolled-back app with "Invalid installation" or a Gatekeeper block (the bundle's outer signature still references the patched files' hashes), the cleanest recovery is to reinstall Claude Desktop from https://claude.ai/download - about a minute, and you get a fresh signed copy.
The model-resolution function in app.asar has two JS gates that both must pass for [1m] to be appended: a server feature-flag check (3885610113) and a model allow-list. The flag rollback on 2026-03-19 broke the first gate for every Cowork user; the opus-4-7 rollout on 2026-04-18 broke the second for 4-7 sessions. The flag ID is the stable Layer 1a anchor; Layer 1b exists in two forms (regex for Claude Desktop < v1.3109, JS array for ≥ v1.3109) which the preflight auto-detects.
For the full narrative (how the flag was found, why extract/repack fails, how each regression was diagnosed) see docs/root-cause-analysis.md. For the per-layer byte-swap spec see docs/integrity-layers.md.
The app enforces four integrity layers that all break when any file changes. The patch updates them in sequence:
| Layer | What it checks | How the patch handles it |
|---|---|---|
| 1. JS application logic | Two gates in the model-resolution function: server feature flag + model allow-list. | Two same-length JS swaps. Layer 1b's form (regex vs array) rotated between app versions; the preflight auto-detects. Spec: docs/integrity-layers.md § Layer 1. |
| 2. Per-file integrity | SHA256 of index.js in asar header |
Recompute file hash + block hashes, replace in header (same-length). |
| 3. Header integrity | SHA256 of asar header in Info.plist |
Recompute via @electron/asar getRawHeader(), write to plist. |
| 4. Code signature | macOS entitlements for Cowork's VM sandbox | Extract original entitlements before patching, re-sign with --entitlements (not --deep). |
All JS replacements must be same-length - any offset shift invalidates V8's compiled bytecode cache and the app crashes on launch. This is why extract/repack doesn't work. Full per-layer detail: docs/integrity-layers.md.
| Timestamp | Event |
|---|---|
| 2026-03-18 06:51 | [1m] first observed in Cowork sessions |
| 2026-03-19 18:36:58 | Last working session - model: claude-opus-4-6[1m] |
| 2026-03-19 19:59:08 | First broken session - model: claude-opus-4-6 (same app version, flag rollback) |
| 2026-03-31 → 2026-04-06 | 110 consecutive sessions, all without [1m] |
| 2026-04-03 09:08 | Context window exceeded error - confirmed hitting 200K wall |
| 2026-04-18 20:19:30 | Last working opus-4-6[1m] session under flag-bypass-only patch |
| 2026-04-18 20:19:53 | Second regression - first opus-4-7 session, no [1m]. Same app version (1.569.0), flag-bypass patch still installed. Model allow-list regex doesn't recognize 4-7. |
| 2026-04-19 → 04-20 | v1.3109.0 regex→array refactor discovered. Preflight updated to detect both forms; see CHANGELOG.md and docs/root-cause-analysis.md § April 19–20 2026. |
- Minified names change between versions. The script matches by stable byte anchors (flag ID + Layer 1b form); minified variable names are never relied on. When Anthropic refactors the gate again, expect to add a Form C - see docs/integrity-layers.md § Layer 1 for the current anchor set.
Important
Opus-only scope. Layer 1b matches opus-4-6 and opus-4-7 only. sonnet-4-6 is intentionally dropped so the rule is deterministic (as of April 2026: sonnet [1m] is billed at API rates; opus [1m] is bundled in Max - auto-suffixing sonnet would silently route bundled usage onto a metered tab). If/when opus-4-8 ships, update the Layer 1b anchor in patch-claude-1m.sh or open an issue.
- The script is intentionally conservative. If it can't recognize the current build, it exits with
unknownrather than half-patch. Re-run safely. - This modifies the app binary. The script creates a backup on every run. Fully reversible (see Rollback).
- The
ANTHROPIC_DEFAULT_OPUS_MODELenv var doesn't help.LocalAgentModeSessionManagerhas its own model resolution path that ignores environment overrides. - ToS: This is a personal workaround for a documented regression affecting paying customers. Use at your own risk.
- CHANGELOG.md - what changed when, by Claude Desktop version
- docs/integrity-layers.md - the four integrity layers in detail
- docs/root-cause-analysis.md - how the flag was found, why extract/repack fails
- Project writeup - the narrative version of the same material
- Discussions - Q&A, version-compat chatter, bug-report template
- anthropics/claude-code#37413
- anthropics/claude-code#36760
- anthropics/claude-code#36351
- anthropics/claude-code#33154
Note
This repository provides a local patch script and documentation. It does not distribute Anthropic's code, bypass DRM or encryption, or access Anthropic's servers beyond the normal API calls your plan authorizes. You are responsible for evaluating whether use complies with applicable terms and laws in your jurisdiction.
Posture, in one paragraph. The patch operates on the user's locally-installed copy of Claude Desktop, on the user's own hardware, to interoperate with software the user has paid for. No prebuilt binaries are distributed; users run the script themselves against their own installation. Same-length byte swaps in a feature-flag check are not circumvention of a "technological measure that effectively controls access to a copyrighted work" under DMCA §1201(a) (see Chamberlain Group v. Skylink on the access-nexus requirement); to the extent any §1201 reading reached this script, §1201(f)'s interoperability exception applies. CFAA exposure for running the script on hardware the user owns is foreclosed by Van Buren v. United States (2021). The repository is MIT-licensed; "Claude" is used in nominative reference only, as documented in the trademark notice. None of this is legal advice; consult counsel before relying on it in your jurisdiction.

![Claude Desktop /context showing Model: claude-opus-4-7[1m] and 1M token window after the patch](/evanjcosgrove/claude-cowork-1m-patch/raw/main/docs/img/verification.png)