logancyang_obsidian-copilot/docs/agent-mode-and-tools.md
Logan Yang f75c2ebbee
feat(agent-mode): one-click "Report an Issue" flow with screenshot + frame log (#2614)
* feat(agent-mode): one-click "Report an Issue" flow with screenshot + frame log

Reporting an Agent Mode bug was high-friction: the diagnostic frame log
defaulted off (so it usually wasn't capturing when a problem hit), and there
was no in-product path to assemble a report.

- Default `agentMode.debugFullFrames` to ON for new installs so the frame log
  is already capturing when a bug occurs. The existing sanitize migration
  preserves an explicit prior choice (a user who turned it off stays off).
- Add a "Report an Issue" button to the Agent Mode control bar. It opens a
  modal for a note, captures a screenshot of the chat surface (Electron
  capturePage, popout-aware, degrades gracefully), bundles it with the current
  frame log into a timestamped folder, reveals the folder, and opens a
  prefilled GitHub issue.
- Optionally include the OpenCode log when that backend is active, and show an
  in-flow privacy disclosure shown only when the user chooses to share.

Desktop-only; mobile and capture failures degrade to a report without a
screenshot. Adds unit tests for the new default, the preserve-explicit-choice
migration, the bundle assembler, and the opencode-log locator.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(agent-mode): make opencode log attachment opt-in by default

The Report-issue flow bundles opencode's newest *global* log, which may
belong to an unrelated CLI/Desktop session for another project. Defaulting
the checkbox to checked could silently attach that log, exposing unrelated
prompts and tool output. Default it to unchecked so the user opts in.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(agent-mode): cap report issue URL length and document the flow

- buildReportIssueUrl: truncate the prefilled body so the assembled URL
  stays under Electron's ~2081-char openExternal limit on Windows. Without
  this, a long note made openExternal reject silently while the success
  notice still claimed the issue page opened. The full report is preserved
  in report.md on disk, and the truncated body points the user there.
- Document the Report an Issue flow (bundle contents, drag-drop attach,
  privacy note, opt-in OpenCode log) in docs/agent-mode-and-tools.md per
  DOCS_GUIDE.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(agent-mode): skip frame log in report when logging is disabled

If a user turns off "Log Full Agent Mode Frames" but a stale
acp-frames.ndjson still exists in the temp dir, the report assembler would
copy that old file into the bundle, leaking plaintext prompts/tool output
despite logging being opted out. Only bundle the frame log when
debugFullFrames is currently enabled.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(agent-mode): file reports to public repo; clarify report UX and settings

Addresses review feedback on the Report an Issue flow:

- File user reports to the PUBLIC logancyang/obsidian-copilot repo (label
  "bug"), never the private preview repo, which users can't see.
- Report modal: state plainly that the screenshot is of the Agent Mode chat
  pane (not the whole screen), spell out what "Prepare report" does (save
  files to a folder, open it, open a prefilled GitHub issue to attach them),
  and replace the obscure muted disclaimer with a prominent warning callout.
- Advanced settings: split Agent Mode logging into its own "Agent Mode
  debugging" section with plain-language copy (renamed to "Keep an Agent Mode
  activity log" / "Agent Mode activity log file"), and clarify that the legacy
  Debug Mode / Create Log File tools are for the regular chat, not Agent Mode.
- Update docs to match.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* feat(agent-mode): move Report an Issue to the Advanced settings section

Per UX feedback, the entry point moves out of the agent chat control bar into
Settings → Advanced → Agent Mode debugging, alongside the activity-log
controls it relates to.

- Remove the bug-icon button and its wiring from AgentChatControls/AgentHome.
- Add a "Report an Issue" button to the Agent Mode debugging settings section.
- ReportIssueModal now resolves its screenshot target lazily via
  resolveCaptureTarget(): the settings caller closes the Settings window and
  reveals the agent pane first, so the screenshot is still the chat surface
  (not the dialog). No agent pane open -> screenshot is skipped gracefully.
- Export ReportIssueModal from the agentMode barrel so host code can reach it
  without crossing the ui boundary.
- Update docs to point at the new location.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(agent-mode): honor opencode env overrides when finding its log

OpencodeBackend spawns opencode with `{ ...process.env, ...envOverrides }`, so a
user who relocates opencode's data dir via XDG_DATA_HOME/HOME overrides has its
logs written there. The report's opencode-log lookup only consulted ambient
process.env/homedir, so it could attach an unrelated global log or miss the
active session's. Resolve the log path from the same merged env + HOME override.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(agent-mode): report uses active session backend; gate import on desktop

Two review fixes for the settings-based Report an Issue button:

- Read the backend from the active Agent Mode session, not the persisted
  default. Switching tabs across backends changes the active session without
  touching settings.agentMode.activeBackend, so the modal could hide/show the
  OpenCode-log option for the wrong tab and name the wrong backend in the env
  block.
- Check isDesktopRuntime() before importing the @/agentMode barrel. On mobile
  the barrel evaluates Node-only modules; importing before the modal's own
  desktop guard could reject during module load instead of showing the
  desktop-only notice. Mirrors the existing frame-log buttons.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 16:43:26 -07:00

8 KiB

Agent Mode and Tools

Copilot Plus includes an autonomous agent that can reason step-by-step and decide which tools to use to answer your question. Instead of you specifying every step, the agent figures out what to do on its own.

This feature requires a Copilot Plus license.


Overview

When the autonomous agent is enabled, Copilot can:

  1. Break down your request into sub-tasks
  2. Use tools to gather information (search your vault, search the web, read a note)
  3. Create or edit notes
  4. Combine results and give you a comprehensive answer

Example: Ask "What did I work on last week?" and the agent will automatically search your vault for dated notes from the past 7 days, read the relevant ones, and summarize your week.


Enabling Agent Mode

  1. Go to Settings → Copilot → Plus
  2. Turn on Enable Autonomous Agent

The agent activates automatically when you're in Copilot Plus mode. You don't need to do anything special — just ask your question.

Max Iterations

The agent works in iteration cycles (think → use a tool → think → use a tool → answer). You can control the maximum number of iterations before the agent stops:

  • Default: 4 iterations
  • Maximum: 16 iterations
  • Setting: Settings → Copilot → Plus → Autonomous Agent Max Iterations

The agent also has a maximum runtime of 5 minutes per response, regardless of iteration count.


Available Tools

Copilot Plus has 13 built-in tools. Some are always active; others can be enabled or disabled.

Always-Enabled Tools

These tools are always available and cannot be disabled:

Get Current Time

Gets the current time in any timezone. Useful for time-aware queries like "what should I do today?"

Get Time Range

Converts natural time expressions (like "last week" or "yesterday") into exact date ranges. Usually called automatically before a time-based vault search.

Get Time Info

Converts an epoch timestamp to a human-readable date and time.

Convert Timezones

Converts a time from one timezone to another. Ask: "What time is 3pm EST in Tokyo?"

Read Note

Reads the content of a specific note. The agent uses this to inspect a note it found via search, or that you mentioned explicitly. Works on large notes by reading them in chunks.

File Tree

Browses the file structure of your vault. The agent uses this to find folder paths before creating new notes or to count files in a folder.

Tag List

Lists all tags in your vault with usage statistics. Useful for tag reorganization or finding notes by tag patterns.

Update Memory

Saves information to your memory when you explicitly ask the AI to remember something. See Copilot Plus and Self-Host for details.

Requires: Settings → Copilot → Plus → Reference Saved Memories must be enabled. If this setting is off, the tool is not registered and memory commands will not work.

Configurable Tools

These tools can be individually enabled or disabled in Settings → Copilot → Plus → Tool Settings:

Searches your vault notes by content. The agent uses this to find notes relevant to your question.

  • Trigger: Automatically for vault-related questions, or explicitly with @vault
  • Uses: Both semantic search (if enabled) and lexical search

Searches the internet for current information.

  • Trigger: Automatically when your question implies web/online content, or explicitly with @websearch or @web
  • Requires: A web search service configured (Firecrawl or Perplexity in self-host mode, or handled by Plus)

Write to File

Creates a new note or overwrites an existing one entirely.

  • Trigger: Automatically for "create a note" requests, or explicitly with @composer (available in both Copilot Plus and Projects mode)
  • Behavior: Shows a preview of the content before writing. You can review and accept or reject the change.
  • Auto-accept: Enable Settings → Copilot → Plus → Auto-accept edits to skip the preview

Replace in File

Makes targeted changes to an existing note using search-and-replace blocks.

  • Use case: Small edits (adding a bullet, updating a section) — more precise than rewriting the whole note
  • Behavior: Shows a diff preview before applying the change
  • Auto-accept: Same setting as Write to File

YouTube Transcription

Fetches the transcript of a YouTube video.

  • Trigger: Automatically when you paste a YouTube URL in your message
  • No extra setup needed: Just include the URL in your message
  • Self-host option: Use your own Supadata API key for transcription in self-host mode

Tool Settings

Go to Settings → Copilot → Plus → Tool Settings to:

  • See all available tools
  • Enable or disable individual configurable tools
  • View what each tool does

Using Tools Explicitly

While the agent automatically decides when to use tools, you can also trigger them explicitly with @-mentions:

@vault find all notes about my reading list
@websearch what is the latest version of Python?
@composer create a new meeting notes template
@memory remember that I prefer bullet points for lists

See Context and Mentions for the full @-mention reference.


Tool Call Indicators

While the agent is working, the chat shows status indicators for each tool call:

  • "Reading files"
  • "Searching the web"
  • "Reading file tree"
  • "Compacting"

This lets you see what the agent is doing as it works.


File Editing: Preview and Diff

When the agent uses Write to File or Replace in File, it shows a preview before making changes:

  • Split view: Before/after shown side by side
  • Side-by-side view: Changes highlighted inline

You can choose your preferred diff view in Settings → Copilot → Plus → Diff View Mode.

Review the proposed change and click:

  • Accept — Apply the change to your note
  • Reject — Discard without making any changes
  • Revert — Undo a change that was already accepted

Auto-Accept Edits

If you trust the agent and don't want to review every file change, enable Auto-accept edits in Settings → Copilot → Plus. File changes will be applied immediately without a confirmation step.


Reporting an Issue

When something goes wrong in Agent Mode, the Report an Issue button under Settings → Copilot → Advanced → Agent Mode debugging bundles everything a maintainer needs to diagnose it.

Clicking it opens a short form where you describe what happened. When you submit, Copilot:

  1. Saves a screenshot of the Agent Mode chat pane (just the agent panel, not your whole screen).
  2. Saves a recent Agent Mode log of the behind-the-scenes messages between Copilot and the agent. This log is captured automatically so a report always has recent activity to include; you can turn it off under Settings → Copilot → Advanced → Keep an Agent Mode activity log.
  3. Opens the folder containing those files in your file manager.
  4. Opens a prefilled GitHub issue in your browser.

The files are not uploaded for you — drag them from the opened folder into the GitHub issue to attach them.

Privacy note: The Agent Mode log can contain your prompts, note contents, and tool inputs/outputs in plaintext. Review the saved files before sharing them publicly.

Including the OpenCode log

When the OpenCode backend is active, the form shows an optional checkbox to include OpenCode's own log. It is off by default because OpenCode's log is shared across all of your OpenCode sessions, so it may contain activity from unrelated projects. Turn it on only when the issue involves the OpenCode backend itself.

This feature is available on desktop only.