fix: remove dead getCdpToolReference and unused prompt exports#493
Merged
shadowfax92 merged 2 commits intomainfrom Mar 12, 2026
Merged
fix: remove dead getCdpToolReference and unused prompt exports#493shadowfax92 merged 2 commits intomainfrom
shadowfax92 merged 2 commits intomainfrom
Conversation
The getCdpToolReference function was always excluded by the AI SDK agent (tool schemas are injected by the SDK itself) and never used by the MCP server (which has its own MCP_INSTRUCTIONS). Also removes unused exports getSystemPrompt and PROMPT_SECTION_KEYS. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
|
@greptileai review |
Contributor
Greptile SummaryThis PR performs pure dead-code removal in the server's agent prompt system: it deletes the Key changes:
Minor opportunity missed: The sibling Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["AiSdkAgent.create()"] --> B["excludeSections = []"]
B --> C{isScheduledTask?}
C -- yes --> D["push 'tab-grouping'\n(dead - section removed in PR#388)"]
C -- no --> E["Check chatMode or isScheduledTask"]
D --> E
E -- yes --> F["push 'nudges'"]
E -- no --> G["buildSystemPrompt(options)"]
F --> G
G --> H["Filter promptSections\nby exclude set"]
H --> I["Assembled prompt sections:\nintro, security-boundary, strict-rules,\ncomplete-tasks, observe-act-verify,\nhandle-obstacles, error-recovery,\nexternal-integrations, style,\nworkspace, page-context,\nuser-preferences, soul, memory,\nskills, security-reminder"]
I --> J["Return AGENT_PROMPT"]
style D fill:#ffe0b2,stroke:#f57c00
Prompt To Fix All With AIThis is a comment left during a code review.
Path: apps/server/src/agent/ai-sdk-agent.ts
Line: 122-124
Comment:
**Missed dead exclusion — `tab-grouping` no longer exists in `promptSections`**
Commit `f74c353` (PR #388) removed the `'tab-grouping'` entry from the `promptSections` map in `prompt.ts`, but the corresponding `excludeSections.push('tab-grouping')` was never cleaned up. As a result this push is a no-op — `buildSystemPrompt` will simply ignore an exclude key that has no matching section. Since this PR is explicitly removing dead section-exclusion logic (the adjacent `'tool-reference'` exclusion), this leftover can be removed at the same time.
```suggestion
const excludeSections: string[] = []
if (config.resolvedConfig.isScheduledTask) {
}
```
Or, if the entire `isScheduledTask` branch is now empty, it can be dropped entirely:
```
const excludeSections: string[] = []
if (
config.resolvedConfig.isScheduledTask ||
config.resolvedConfig.chatMode
) {
excludeSections.push('nudges')
}
```
**Rule Used:** Remove unused/dead code rather than leaving it in ... ([source](https://app.greptile.com/review/custom-context?memory=9b045db4-2630-428c-95b7-ccf048d34547))
**Learnt From**
[browseros-ai/BrowserOS-agent#126](https://github.com/browseros-ai/BrowserOS-agent/pull/126)
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: a8274b6 |
4 tasks
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.
Summary
getCdpToolReference()function (~70 lines) — always excluded by the AI SDK agent and never used by the MCP server'tool-reference'frompromptSectionsmap and its exclusion logic inai-sdk-agent.tsgetSystemPrompt()andPROMPT_SECTION_KEYSDesign
Pure dead code removal. The CDP tool reference was originally kept for "MCP prompt serving where clients lack tool definitions," but the MCP server has its own separate
MCP_INSTRUCTIONSand never uses this function. The AI SDK agent always excluded it since tool schemas are injected by the SDK itself.Test plan
bun run lintpasses (773 files checked, no issues)bun run --filter '@browseros/server' typecheckpassesgetCdpToolReference,getSystemPrompt, orPROMPT_SECTION_KEYS🤖 Generated with Claude Code