Skip to content

fix: remove dead getCdpToolReference and unused prompt exports#493

Merged
shadowfax92 merged 2 commits intomainfrom
fix/update-prompt
Mar 12, 2026
Merged

fix: remove dead getCdpToolReference and unused prompt exports#493
shadowfax92 merged 2 commits intomainfrom
fix/update-prompt

Conversation

@shadowfax92
Copy link
Contributor

Summary

  • Remove getCdpToolReference() function (~70 lines) — always excluded by the AI SDK agent and never used by the MCP server
  • Remove 'tool-reference' from promptSections map and its exclusion logic in ai-sdk-agent.ts
  • Remove unused exports getSystemPrompt() and PROMPT_SECTION_KEYS

Design

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_INSTRUCTIONS and never uses this function. The AI SDK agent always excluded it since tool schemas are injected by the SDK itself.

Test plan

  • bun run lint passes (773 files checked, no issues)
  • bun run --filter '@browseros/server' typecheck passes
  • No other files import getCdpToolReference, getSystemPrompt, or PROMPT_SECTION_KEYS

🤖 Generated with Claude Code

shadowfax92 and others added 2 commits March 12, 2026 14:15
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>
@shadowfax92
Copy link
Contributor Author

@greptileai review

@github-actions github-actions bot added the fix label Mar 12, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 12, 2026

Greptile Summary

This PR performs pure dead-code removal in the server's agent prompt system: it deletes the getCdpToolReference() function (~76 lines), removes its 'tool-reference' entry from promptSections, clears the matching initial exclusion in AiSdkAgent, and drops the now-unused PROMPT_SECTION_KEYS and getSystemPrompt() public exports.

Key changes:

  • getCdpToolReference() removed from prompt.ts — was always excluded by the AI SDK agent (tool schemas are injected by the SDK) and never used by the MCP server (which has its own MCP_INSTRUCTIONS)
  • 'tool-reference' removed from the promptSections map
  • excludeSections initial value in ai-sdk-agent.ts updated from ['tool-reference'] to []
  • PROMPT_SECTION_KEYS and getSystemPrompt() removed as confirmed unused exports
  • Version bumped to 0.0.74

Minor opportunity missed: The sibling excludeSections.push('tab-grouping') line is also dead code — the 'tab-grouping' section was already deleted from promptSections in PR #388 but its exclusion was never cleaned up from ai-sdk-agent.ts. Since this PR targets exactly this kind of dead exclusion logic, removing it here would be a natural follow-up.

Confidence Score: 5/5

  • Safe to merge — all removed code is confirmed dead, no callers exist, and typecheck passes.
  • All removed symbols (getCdpToolReference, getSystemPrompt, PROMPT_SECTION_KEYS, 'tool-reference' exclusion) are genuinely unreferenced and their removal has no functional impact. The only comment is a style note about a pre-existing dead exclusion that was missed in a previous PR; it does not block merging.
  • No files require special attention — the change is straightforward dead-code removal with a version bump.

Important Files Changed

Filename Overview
apps/server/src/agent/prompt.ts Removes dead getCdpToolReference() function (~76 lines), its 'tool-reference' entry from promptSections, and the unused PROMPT_SECTION_KEYS + getSystemPrompt() exports. Remaining code is unaffected.
apps/server/src/agent/ai-sdk-agent.ts Removes the initial ['tool-reference'] exclusion from excludeSections. A sibling exclusion — excludeSections.push('tab-grouping') — remains but references a prompt section that was deleted in commit f74c353 and no longer exists in promptSections; it is dead code that could be cleaned up alongside this change.
apps/server/package.json Version bump from 0.0.73 to 0.0.74 to reflect this dead-code cleanup release.
bun.lock Lockfile updated to reflect the version bump in apps/server/package.json — no dependency changes.

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
Loading
Prompt To Fix All With AI
This 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

@shadowfax92 shadowfax92 merged commit 7c89198 into main Mar 12, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant