Skip to content

Conversation

@lerouxb
Copy link
Contributor

@lerouxb lerouxb commented Dec 18, 2025

This is copied liberally from Gagik's PoC with minimal changes so far.

To try it out you'll have to toggle the "enable tool calling" feature flag. All this UI will be switched out to use leafygreen's tool card soon once that's ready. For now it is just functional placeholders.

There are a few flows that are probably best tested with e2e tests. Especially since it is centred around the temporary tool call cards.

Screenshot 2025-12-18 at 17 25 43 Screenshot 2025-12-18 at 17 25 47 Screenshot 2025-12-18 at 17 25 57 Screenshot 2025-12-18 at 17 26 01

chat.messages = [...chat.messages, contextPrompt];
}

const { enableToolCalling } = preferences.getPreferences();
Copy link
Contributor Author

@lerouxb lerouxb Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something I'm probably gonna have to check with Sergey when he's back, but the preferences hook isn't working well here - it caches the initial value so it doesn't respond if you toggle the flag from the preferences modal.

This way at least works for now.

@github-actions github-actions bot added the feat label Dec 18, 2025
@lerouxb lerouxb added the feature flagged PRs labeled with this label will not be included in the release notes of the next release label Dec 18, 2025
isMyQueriesEnabled;

const query = useQueryBarQuery();
useSyncAssistantGlobalState('currentQuery', query);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea where the best place would be to sync the query. This was the most minimally invasive way I could quickly think of that's guaranteed to be "in sync".

: 'No output available';
const hasOutput = toolCall.state === 'output-available';

const isAwaitingApproval = toolCall.state === 'approval-requested';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a component which returns a different thing based on a switch statement instead? not too sure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think whatever we choose to do here we'll probably be revising it in the database tool calling PR and onwards.

const editorInitialValueRef = useRef<string>(pipelineText);
const editorCurrentValueRef = useCurrentValueRef<string>(pipelineText);

useSyncAssistantGlobalState('currentAggregation', pipelineText);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the pipeline as text editor case we happen to already have the pipeline text. So I think this should at least be performant enough?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I lack context about implications of this so maybe second opinion is good but sgtm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in this case I'm more sure that it is fine. I'm more concerned about the builder path.

const mapState = (state: RootState) => {
return {
stagesIdAndType: state.pipelineBuilder.stageEditor.stagesIdAndType,
pipelineText: getPipelineTextFromStages(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case I can't think of a better way to calculate the pipeline text. The usual machinery is only accessible from redux land because it uses pipelineBuilder. The stages on the state are of a different type to the ones the aggregation builder and therefore it isn't easy to just factor out a utility function.

And then the builder has all these invalid / partial states. I'm attempting to just skip those stages. Maybe we want just the most recent valid pipeline, maybe we want the partial states and every syntax error so the model can do something with it?

Maybe I'm overthinking it and this is fine for now.

@lerouxb lerouxb marked this pull request as ready for review December 22, 2025 15:00
@lerouxb lerouxb requested a review from a team as a code owner December 22, 2025 15:00
@lerouxb lerouxb requested review from Copilot and tculig December 22, 2025 15:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements basic tool calling functionality in Compass Assistant, allowing the AI to access current query and aggregation state through a new "get-compass-context" tool. Tool calls are displayed as interactive cards that require user approval before execution.

Key changes:

  • Added ToolsController to manage tool registration and execution
  • Implemented tool call UI with expandable input/output sections and approval buttons
  • Integrated query/aggregation state tracking for the assistant to access
  • Updated system prompts to reflect tool calling capabilities

Reviewed changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/compass/src/app/components/home.tsx Added ToolsControllerProvider wrapper
packages/compass-web/src/entrypoint.tsx Added ToolsControllerProvider and fixed formatting
packages/compass-query-bar/src/components/query-bar.tsx Syncs current query to assistant global state
packages/compass-query-bar/package.json Added compass-assistant dependency
packages/compass-generative-ai/src/tools-controller.ts New ToolsController class for managing tools
packages/compass-generative-ai/src/provider.tsx Added ToolsController provider and context
packages/compass-assistant/src/prompts.ts Updated prompts to include tool calling instructions
packages/compass-assistant/src/prompts.spec.ts Updated test expectations for new prompt format
packages/compass-assistant/src/docs-provider-transport.ts Added tools support to transport layer
packages/compass-assistant/src/components/tool-call-message.tsx New component for rendering tool call cards
packages/compass-assistant/src/components/assistant-chat.tsx Integrated tool call rendering and approval handling
packages/compass-assistant/src/compass-assistant-provider.tsx Wired up ToolsController and preferences
packages/compass-assistant/src/compass-assistant-provider.spec.tsx Added tests for tool calling feature
packages/compass-assistant/src/assistant-global-state.tsx Changed query/aggregation types from object to string
packages/compass-assistant/src/@ai-sdk/react/use-chat.ts Exposed addToolApprovalResponse method
packages/compass-aggregations/.../pipeline-builder-ui-workspace/index.tsx Syncs aggregation pipeline text to assistant global state
packages/compass-aggregations/.../pipeline-as-text-workspace/pipeline-editor.tsx Syncs aggregation pipeline text to assistant global state

@lerouxb lerouxb removed the request for review from tculig December 22, 2025 16:28
@lerouxb lerouxb changed the title feat(compass-assistant): add basic tool calling & tool cards COMPASS-10144 feat(compass-assistant): add basic tool calling & placeholder tool cards COMPASS-10144 Dec 22, 2025
Copy link
Contributor

@gagik gagik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments, LGTM otherwise

@lerouxb lerouxb merged commit bd69de7 into main Dec 23, 2025
83 of 84 checks passed
@lerouxb lerouxb deleted the tool-calling branch December 23, 2025 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat feature flagged PRs labeled with this label will not be included in the release notes of the next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants