Files
deepagents/libs/code/deepagents_code/_constants.py
Mason Daugherty b1600a8da7 feat(code): /tools slash command (#4649)
Deep Agents Code now supports `/tools`, which lists the built-in and MCP
tools available to the current agent.

---

Adds an interactive `/tools` slash command to the `deepagents-code` TUI
so users can see the tools available to the current agent, grouped into
built-in tools and tools from each MCP server. MCP servers that are
disabled, need login, or failed to load are shown separately instead of
disappearing from the list.

For managed sessions, built-in tools are enumerated off the UI thread
with a credential-free agent compile. For preconfigured local agents,
`/tools` inspects the active graph directly so custom tool sets remain
authoritative. When a custom or remote agent cannot be inspected, the
command explains that limitation rather than incorrectly reporting that
no tools are available.

MCP entries reuse the metadata loaded for the running agent instead of
starting discovery inside Textual's live event loop. If `/mcp`
configuration changes are waiting for a reconnect, `/tools` keeps using
the pre-change snapshot so its output continues to match the tools the
agent can currently invoke.

The catalog is rendered as a chat message, like `/tokens`, and is
discoverable through `/help`, command completion, and a startup tip.

Made by [Open
SWE](https://openswe.vercel.app/agents/626ca1ec-726e-58e8-7dae-4e85363c953d)

## References

- Plan:
https://openswe.vercel.app/agents/626ca1ec-726e-58e8-7dae-4e85363c953d/plan

---------

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
2026-07-13 03:13:37 -04:00

42 lines
1.7 KiB
Python

"""Lightweight shared constants for the app.
This module is intentionally dependency-free (no third-party imports, no
sibling-module imports) so any other module — including the startup-critical
`main.py` and the heavy `agent.py` — can import from it without triggering a
chain of expensive imports.
"""
from __future__ import annotations
from typing import Final
DEFAULT_AGENT_NAME: Final[str] = "agent"
"""Default agent / assistant identifier when no `-a` flag is given."""
FIREWORKS_PROVIDER_ID_PREFIX: Final[str] = "accounts/fireworks/"
"""Prefix used to infer Fireworks from fully-qualified IDs."""
FIREWORKS_MODEL_ID_PREFIXES: Final[tuple[str, ...]] = (
"accounts/fireworks/models/",
"accounts/fireworks/routers/",
)
"""Model and router ID prefixes used for stripping and classification."""
MCP_REENABLED_PENDING_ERROR: Final[str] = "Re-enabled — press Ctrl+R to load."
"""User-facing reconnect guidance shown for an MCP server that was optimistically
re-enabled but whose agent has not yet reconnected.
Set as `MCPServerInfo.error` by `app._apply_optimistic_disabled_state` (alongside
`pending_reconnect=True`, which is what `/tools` actually keys off). Named here
so the producer and the tests asserting the message share one literal.
"""
SYSTEM_MESSAGE_PREFIX: Final[str] = "[SYSTEM]"
"""Prefix for synthetic human messages (e.g. interrupt cancellation notices).
Such messages are written to the `messages` channel for the agent's benefit on
resume but are not user-authored, so they are filtered out of both the rendered
transcript and a thread's initial prompt. Shared here so the single producer
(`textual_adapter`) and its consumers (`app`, `sessions`) agree on one literal.
"""