Skip to content

Create set of tool names once in getCoreSystemPrompt #18261

@jerop

Description

@jerop

For performance, it's better to create the Set of tool names once at the beginning of the getCoreSystemPrompt method, rather than creating it inside this factory function every time it's called. This also allows you to reuse the Set for other checks.

I suggest adding this at the top of the function:

const enabledToolNames = new Set(toolNames);

Then you can use enabledToolNames.has(t) here. This would also be beneficial for the primaryWorkflows section, where toolNames.includes(...) can be replaced with enabledToolNames.has(...) for an O(1) lookup instead of O(n).

            planModeToolsList: PLAN_MODE_TOOLS.filter((t) =>
              enabledToolNames.has(t),

Originally posted by @gemini-code-assist[bot] in #18258 (comment)

Metadata

Metadata

Assignees

Labels

area/coreIssues related to User Interface, OS Support, Core Functionalitystatus/need-triageIssues that need to be triaged by the triage automation.workstream-rollupLabel used to tag epics and features that are associated with one of the three primary workstreams🔒 maintainer only⛔ Do not contribute. Internal roadmap item.

Type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions