Skip to content

Mark Text Tool

The mark_text tool annotates spans within text using XML-style tags according to caller-supplied instructions. It accepts either inline text or a file path.

Quick start

Ensure your settings declare an LLM and point the tool at it:

# ~/.config/aifred-tk/settings.yml
llms:
  my-llm:
    provider: openai
    model: gpt-4o-mini

tools:
  mark_text:
    llm:
      type: ref
      ref: my-llm

Then invoke the tool:

aifred-tk mark_text --text "Python service" --instructions "mark technology terms as technological"

Output:

<technological>Python</technological> service

Configuration

LLM setting

The tools.mark_text.llm key is required. It accepts a reference to a named LLM or an inline definition. See LLMs for the full format.

# Reference a named LLM
tools:
  mark_text:
    llm:
      type: ref
      ref: my-llm

Enabling and disabling

The tool respects the standard enabled flag:

tools:
  mark_text:
    enabled: false

Usage

CLI

aifred-tk mark_text (--text TEXT | --file-path PATH) --instructions TEXT [--context TEXT]
Option Description
--text TEXT Inline text to mark. Mutually exclusive with file_path.
--file-path PATH Path to a UTF-8 text file to mark. Mutually exclusive with text.
--instructions TEXT Marking instructions describing what to annotate and how (max 500 characters). Required.
--context TEXT Optional domain hint to resolve ambiguous terms (max 500 characters).

MCP

The tool is registered automatically when the MCP server starts. Invoke it as aifred_mark_text with the required instructions and either text or file_path.

Output

Result (status: ok)

On success, marked_text contains the annotated text.

{
  "status": "ok",
  "marked_text": "<technological>Python</technological> service"
}

Error (status: error)

{"status": "error", "message": "Provide exactly one of 'text' or 'file_path', not both or neither."}
{"status": "error", "message": "File not found: src/missing.py"}
{"status": "error", "message": "File exceeds the 1 MB size limit (2097152 bytes)."}
{"status": "error", "message": "Agent error: <provider error details>"}

Limits and security

  • .aiignore — when using file_path, mark_text checks for .aiignore files from the target path up to the filesystem root. Matching files are refused immediately.
  • Size limit — files or inline text are limited to ensure stability. Files larger than 1 MB (1,048,576 bytes) are rejected. Inline text is capped at 100,000 characters.
  • Prompt injection isolation — the text content, marking instructions, and optional context are wrapped in XML isolation markers (<marking_instructions>, <text_content>, and <context>) before being forwarded to the agent. This prevents the text content from being interpreted as instructions.