Skip to content

feat(ai): add capabilities, docs, caching - #10052

Merged
Light2Dark merged 5 commits into
mainfrom
ai-web-capabilities-and-docs
Jul 8, 2026
Merged

Light2Dark merged 5 commits into
mainfrom
ai-web-capabilities-and-docs

Conversation

@Light2Dark

@Light2Dark Light2Dark commented Jul 2, 2026 •

Copy link
Copy Markdown
Member

📝 Summary

image
  • Enable provider-adaptive web search, fetch, and X search in the chat panel via pydantic-ai capabilities, using local DuckDuckGo/markdownify fallbacks when installed or provider-native tools when the model supports them
  • Consolidate agent creation and per-provider model settings so code mode and other chat modes share the same path, including OpenRouter/Bedrock caching settings
  • Document chat tool availability by mode, code mode's execute_code toolset, and how to enable web capabilities
  • Add caching to supported providers

📋 Pre-Review Checklist

  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • Video or media evidence is provided for any visual changes (optional).

✅ Merge Checklist

  • I have read the contributor guidelines.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Tests have been added for the changes made.

Made with Cursor

@Light2Dark Light2Dark added documentation Improvements or additions to documentation enhancement New feature or request labels Jul 2, 2026
@vercel

vercel Bot commented Jul 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jul 7, 2026 3:53am

Request Review

@Light2Dark Light2Dark changed the title feat(ai): add provider-adaptive web capabilities and document chat tools feat(ai): add capabilities, docs, caching Jul 2, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 9 files

Architecture diagram
sequenceDiagram
    participant Client as Browser / Chat UI
    participant Route as API Route (stream_completion)
    participant Provider as CompletionProvider
    participant CapRes as CapabilityResolver
    participant Agent as Pydantic Agent
    participant Model as Provider Model
    participant Local as Local Fallback (ddgs/markdownify)
    participant Native as Native Provider Tool

    Note over Client,Native: Chat Completion with Capabilities & Caching

    Client->>Route: POST /api/ai/completion (messages, mode, model, max_tokens)
    Route->>Provider: stream_completion(messages, system_prompt, max_tokens, span_info)

    Provider->>Provider: create_agent(name, max_tokens, tools, system_prompt)

    Provider->>Provider: _build_model_settings(model, max_tokens)
    alt Anthropic / OpenRouter / Bedrock provider
        Provider->>Provider: Set caching flags (anthropic_cache, bedrock_cache, openrouter_route)
    else Other providers
        Provider->>Provider: No caching flags
    end

    Provider->>CapRes: _build_agent_capabilities(model)
    CapRes->>CapRes: Check installed packages (ddgs, markdownify)
    alt Local packages installed
        CapRes->>Local: Use DuckDuckGo/Markdownify as capabilities
    else No local packages
        CapRes->>CapRes: Check provider profile for native support
        alt Provider supports native web search/fetch
            CapRes->>Native: Use provider-native WebFetch, WebSearch, XSearch
        else No native support
            CapRes->>CapRes: No web capabilities enabled
        end
    end
    CapRes-->>Provider: List of AbstractCapability

    Provider->>Agent: Agent(model, model_settings, toolsets, capabilities, instructions)
    Agent->>Model: Model with settings (max_tokens, caching, thinking)

    Provider->>Provider: Stream response via VercelAIAdapter

    alt Streaming path
        Provider->>Agent: run_stream(messages)
        Agent->>Agent: Process conversation, invoke capabilities as needed
        Agent-->>Provider: Stream of events
    else Completion path (non-streaming)
        Provider->>Agent: run(messages)
        Agent-->>Provider: Result object
    end

    Provider-->>Route: StreamingResponse or result
    Route-->>Client: SSE events or JSON response
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread docs/guides/editor_features/tools.md Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 expands marimo’s AI chat integration by adding provider-adaptive web capabilities (search/fetch/X), consolidating agent/model configuration so all chat modes share the same provider path, and documenting tool availability and code mode behavior. It also introduces provider-specific caching settings and updates tests/docs to reflect the new settings/capabilities model.

Changes:

  • Refactors providers to build request settings via _build_model_settings(...), adds provider-adaptive capabilities, and updates telemetry tool counting to include capabilities.
  • Adds provider caching settings (Anthropic/OpenRouter/Bedrock) and makes custom provider construction more generic via signature inspection.
  • Updates docs and skill reference copy, and extends test coverage for capabilities, caching, and custom-provider behavior.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/_server/ai/test_providers.py Updates/extends provider tests for model settings, caching, capability-aware telemetry, and custom provider behavior.
tests/_server/ai/skills/test_skills_utils.py Updates assertions to match new “loaded on demand” reference wording.
marimo/_server/ai/skills/marimo-pair/references/rich-representations.md Removes “do not read from disk” phrasing; keeps capability-loading note.
marimo/_server/ai/skills/marimo-pair/references/notebook-improvements.md Same reference copy adjustment for on-demand loading.
marimo/_server/ai/skills/marimo-pair/references/gotchas.md Same reference copy adjustment for on-demand loading.
marimo/_server/ai/providers.py Core refactor: unified agent creation path, provider-adaptive capabilities, caching settings, and custom provider instantiation changes.
marimo/_dependencies/dependencies.py Adds optional deps (ddgs, markdownify) used for local web search/fetch fallbacks.
docs/guides/editor_features/tools.md Documents per-mode tool availability plus web capability enablement and code mode toolset.
docs/guides/editor_features/ai_completion.md Updates chat mode descriptions, including manual-mode web capability behavior and code mode entry.

Comment thread marimo/_server/ai/providers.py Outdated
Comment thread marimo/_server/ai/providers.py Outdated
Comment thread marimo/_server/ai/providers.py
Comment thread marimo/_server/ai/providers.py
Comment thread marimo/_server/ai/providers.py
@Light2Dark
Light2Dark marked this pull request as ready for review July 2, 2026 17:01
@Light2Dark
Light2Dark requested a review from akshayka as a code owner July 2, 2026 17:01
@Light2Dark
Light2Dark requested a review from manzt July 2, 2026 17:01
- **Ask**: Enables read-only [AI tools](tools.md) and [tools from added MCP Client servers](mcp.md#mcp-client) for context gathering, allowing the assistant to inspect your notebooks
- **Agent** (beta): Enables all tools in **Ask Mode** plus additional tools to [edit notebook cells (add, remove, update) and run stale cells](tools.md#editing-agent-mode-only).
- **Agent**: Enables all tools in **Ask Mode** plus additional tools to [edit notebook cells (add, remove, update) and run stale cells](tools.md#editing-agent-mode-only)
- **Code mode**: Gives the assistant access to the notebook kernel via [`execute_code`](tools.md#code-mode) which allows powerful debugging, exploration, and manipulation of your notebook.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

execute_code is a low-level concept that we shouldn't expose in the docs.

Gives the assistant access to the notebook kernel, which allows the assistant to inspect the marimo runtime and manipulate the notebook in powerful ways.

@manzt may have other wordsmithing suggestions

Comment thread docs/guides/editor_features/tools.md Outdated
Comment thread docs/guides/editor_features/tools.md Outdated
Light2Dark and others added 5 commits July 7, 2026 11:52
Enable web search, fetch, and X search via pydantic-ai capabilities based on
installed local deps or model-native tool support. Consolidate agent creation
and per-provider model settings so code mode and chat share the same path.

Co-authored-by: Cursor <cursoragent@cursor.com>
Explain which tools are available per chat mode and how to enable local or
provider-native web search and fetch.

Co-authored-by: Cursor <cursoragent@cursor.com>
Update create_model docstring, guard inspect.signature introspection,
use explicit None check for Anthropic max_tokens, and use lazy debug logging.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Light2Dark
Light2Dark merged commit 985a19c into main Jul 8, 2026
42 checks passed
@Light2Dark
Light2Dark deleted the ai-web-capabilities-and-docs branch July 8, 2026 02:48
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.14-dev21

williambdean pushed a commit to williambdean/marimo that referenced this pull request Sep 6, 2026
## 📝 Summary

<img width="664" height="893" alt="image"
src="https://github.com/user-attachments/assets/899316c9-e9fa-40da-b1e4-e027ef95ea0b"
/>

- Enable provider-adaptive web search, fetch, and X search in the chat
panel via pydantic-ai capabilities, using local DuckDuckGo/markdownify
fallbacks when installed or provider-native tools when the model
supports them
- Consolidate agent creation and per-provider model settings so code
mode and other chat modes share the same path, including
OpenRouter/Bedrock caching settings
- Document chat tool availability by mode, code mode's `execute_code`
toolset, and how to enable web capabilities
- Add caching to supported providers

## 📋 Pre-Review Checklist

- [ ] For large changes, or changes that affect the public API: this
change was discussed or approved through an issue, on
[Discord](https://marimo.io/discord?ref=pr), or the community
[discussions](https://github.com/marimo-team/marimo/discussions) (Please
provide a link if applicable).
- [x] Any AI generated code has been reviewed line-by-line by the human
PR author, who stands by it.
- [ ] Video or media evidence is provided for any visual changes
(optional).

## ✅ Merge Checklist

- [x] I have read the [contributor
guidelines](https://github.com/marimo-team/marimo/blob/main/CONTRIBUTING.md).
- [x] Documentation has been updated where applicable, including
docstrings for API changes.
- [x] Tests have been added for the changes made.


Made with [Cursor](https://cursor.com)

---------

Co-authored-by: Cursor <cursoragent@cursor.com>

This branch was successfully deployed

1 active deployment
Preview — cf5c2081 Deployed Jul 7, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants