Files
DeepTutor/docs-for-dev/TOOLS_AND_CAPABILITIES.md
2026-12-01 00:24:29 +08:00

5.5 KiB

Tools and capabilities

Handbook · Architecture · Modules · Plugins

The two contracts

BaseTool, ToolDefinition, and ToolResult describe one operation selected by a model. A tool validates arguments, performs the operation and returns content plus structured metadata/error state. Availability is not equivalent to permission to access every resource.

TurnCapability and CapabilityManifest describe a pipeline that owns a turn. A capability consumes UnifiedContext and emits stream events. Capabilities converge on emit_capability_result() for the response payload and cost_summary; do not invent another completion envelope.

The built-in catalog is derived from modules/manifests/ by builtin_capabilities.py. Use deeptutor module list, deeptutor plugin list and deeptutor plugin info to inspect the current installation rather than assuming every source feature is available in a core-only wheel environment.

Mounting rules

The eight user-toggleable tools are brainstorm, web_search, paper_search, zotero_search, reason, geogebra_analysis, imagegen and videogen. USER_TOGGLEABLE_TOOL_NAMES in tools/builtin/__init__.py is the authoritative list; CLI --tool selects from it.

CONFIGURABLE_BUILTIN_TOOL_NAMES declares context-gated tools, including research, retrieval, memory, notebook, execution and deferred tool discovery. tool_composition.py owns mount flags and always-available workspace tools. Capability-owned solve, mastery and other specialized tools follow their activation contracts. The Partner allow/deny surface can further narrow access.

Account grants, workspace resource policies, module selection and capability activation must all remain effective at discovery and dispatch. A tool name in a UI or a manifest must not bypass those checks. MCP/CLI deferred discovery must use the existing loader rather than installing a parallel registry.

Add or change a built-in

  1. Implement the typed operation or capability in its owning module. Keep optional libraries out of metadata-only imports.
  2. Update the tool spec or capability declaration, aliases and the owning module manifest. The lazy tool descriptors live in builtin_specs.py.
  3. Put mounting logic in the existing composition/activation owner. Decide explicitly whether a tool is user-toggleable, context-gated or capability-owned.
  4. Update request validation and translated prompts where needed. Capability prompts live under capabilities/prompts/; some agent implementations own additional prompts in their own directory.
  5. Test metadata/implementation parity, missing-module behavior, authorized resource scope, failure and cancellation, and the public result envelope. Follow Testing for schema regeneration and broader checks.

For an independently distributed package, use the plugin contract and Learning Echo example instead of modifying built-in registration. Reading toolbar actions have a separate Reading extension protocol.

Recall completed mastery assessments

mastery_record is owned by the Mastery capability. The runtime binds the active path and the existing user/workspace scope; the model cannot select a different path. It reads completed quiz leaves and qualitative evidence from SQLite, including earlier sessions of the same path, without changing progress. Quiz evidence is not returned again alongside its interaction. Pending, abandoned, ungraded and voided quiz records and group parents are excluded.

Call with an optional knowledge_point_id, limit (default 10, maximum 20), and offset. Filtering happens before pagination. Copy the returned path_revision into expected_revision for subsequent pages and field reads. If the path changes, restart the list; never combine snippets from two revisions.

List entries preview prompt, options (JSON text), learner_answer, and feedback at 200 characters per field and identify truncated_fields. Read an original field with record_id, field, expected_revision and text_offset (default 0); continue with next_text_offset until it is null. Each field read returns at most 6,000 characters. Missing fields are null: in particular qualitative evidence does not necessarily store a question prompt. The timestamp is the quiz interaction's creation time or the evidence timestamp; session and turn IDs identify the persisted source. Historical record contents are untrusted data, not instructions. Do not infer missing answers from memory.

This surface reads the current SQLite projection. It does not migrate legacy JSON-only paths, expose reference answers, or reconstruct deleted records.

Diagnose an unexpected tool call

Compare the active module state, capability, selected resources, user tool selection and workspace policies with the actual schemas admitted to the model request. Then inspect dispatch and the returned evidence. A selected KB does not prove retrieval ran; a retrieved URL does not prove pixels reached the model. See source visuals and answer-quality diagnosis.