Repository navigation
fix(think): detect real method overrides after Agent wraps methods (#2165) - #2326
Merged
threepointone merged 1 commit intoSep 23, 2026
Conversation
🦋 Changeset detectedLatest commit: 241a28b The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
threepointone
added this pull request to stack #2332
September 23, 2026 14:18
Contributor
⚪ agents import sizesMeasured 343 runtime imports as minified bundles. The primary size is gzip; raw minified size is included for diagnosis. An existing import growing by more than 10% is marked red. This report is informational.
Compared No import sizes changed. All 343 current runtime imports
Reported by agent-think[bot]. |
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
threepointone
force-pushed
the
fix/2165-think-override-detection
branch
2 times, most recently
from
September 23, 2026 14:52
e126d01 to
84974b0
Compare
threepointone
force-pushed
the
fix/2165-think-override-detection
branch
from
September 23, 2026 15:33
84974b0 to
fe6b0d9
Compare
threepointone
force-pushed
the
fix/2165-think-override-detection
branch
from
September 23, 2026 16:42
fe6b0d9 to
878136f
Compare
…2165) Agent's constructor wraps every inherited method and writes the wrapper onto the concrete prototype, so `this.getSystemPrompt !== Think.prototype.getSystemPrompt` is always true and `this.classifyChatError === Think.prototype.classifyChatError` is always false. Every skills-enabled agent logged the getSystemPrompt fallback warning, and reactive overflow recovery without a classifier never warned. Record each subclass prototype's own members before super() runs and check those (plus own class fields) instead of comparing function identity. Also corrects the skills docs, which recommended getSystemPrompt() for always-on behavior even though skills make it fallback-only, and documents the missing-classifier warning. Fixes #2165 Co-authored-by: Sunil Pai <18808+threepointone@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
threepointone
force-pushed
the
fix/2165-think-override-detection
branch
from
September 23, 2026 17:51
878136f to
241a28b
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Agent's constructor wraps every inherited method and writes the wrapper onto the concrete prototype. Think detected overrides by comparing function identity, so after the wrap:this.getSystemPrompt !== Think.prototype.getSystemPromptwas always true, and every skills-enabled agent logged the "getSystemPrompt() is only used as a fallback" warning;this.classifyChatError === Think.prototype.classifyChatErrorwas always false, so reactive overflow recovery without a classifier never warned.Fix
super()runs (and so before the wrap). Override checks read that record, plus own class fields, instead of comparing functions.docs/think/index.mdrecommendedgetSystemPrompt()for always-on behaviour, even though skills make it fallback-only; they are corrected.docs/think/lifecycle-hooks.mddocuments the missing-classifier warning.Validation: Regressions cover a skills agent that inherits the default
getSystemPrompt(no warning), an override inherited from an intermediate subclass and a class-field override (both warn), and reactive overflow recovery with and withoutclassifyChatErroroverridden. The full Think Workers suite andpnpm run checkpassed.Fixes #2165
Authored by @rioyu123 and rebased onto current main, with test strings updated to the current warning text and the docs added. Thanks to @enpitsuLin for the report.
Stacked PR 5 of 10. Base: #2325.