Skip to content

evals: add agent-041-draft-mode-use-cache#9

Draft
gaojude wants to merge 1 commit into
canaryfrom
cursor/draft-mode-use-cache-eval-4209
Draft

evals: add agent-041-draft-mode-use-cache#9
gaojude wants to merge 1 commit into
canaryfrom
cursor/draft-mode-use-cache-eval-4209

Conversation

@gaojude
Copy link
Copy Markdown
Owner

@gaojude gaojude commented Apr 14, 2026

What?

Adds a new agent eval (agent-041-draft-mode-use-cache) that tests whether a coding agent correctly wires draftMode() inside a "use cache" scope — the behavior documented in PR vercel#92794.

Why?

PR vercel#92794 adds documentation about how Draft Mode interacts with cache components. Agents trained on older Next.js patterns may not know that:

  • draftMode().isEnabled is readable inside "use cache" scopes
  • cookies() and headers() are not allowed inside "use cache" (even when draft mode is active)
  • enable()/disable() cannot be called inside cache scopes
  • Cache is automatically bypassed when draft mode is enabled (no cache pollution)

This eval validates that agents reach for the correct modern pattern.

How?

Fixture: A CMS blog app with a /blog/[slug] page that fetches posts via getPost(slug) from lib/cms. The starting state has no caching and no draft mode wiring — the agent must add both.

EVAL.ts (9 assertions):

  1. "use cache" directive is present
  2. draftMode().isEnabled is read inside the cache boundary
  3. draftMode() is properly awaited (Next.js 16 async API)
  4. getPost call is conditional on draft mode status
  5. No enable()/disable() inside cache scope
  6. No cookies()/headers() inside cache scope
  7. next.config enables useCache or cacheComponents
  8. No deprecated caching patterns (unstable_cache, fetch revalidate, dynamicIO)
  9. Route Handler for draft mode still exists with enable/disable

Verified: 9/9 pass against a golden solution, 5/9 fail against the starting fixture.

Slack Thread

Open in Web Open in Cursor 

Frames PR vercel#92794 (docs: draftMode alignment) as an agent eval.

Tests whether a coding agent correctly wires draftMode() inside a
"use cache" scope:
- Uses "use cache" directive for caching
- Reads draftMode().isEnabled inside the cache boundary (async)
- Conditionally fetches draft vs published content
- Does NOT call enable()/disable() inside cache scope
- Does NOT call cookies()/headers() inside cache scope
- Enables useCache or cacheComponents in next.config
- Avoids deprecated caching patterns
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.

2 participants