Skip to main content
Glama

twining_why

Retrieve decision chains with rationale and alternatives to understand why specific code changes were made for any file or module.

Instructions

Retrieve all decisions affecting a given scope or file. Shows the decision chain with rationale, confidence, and alternatives count. Essential for understanding "why was it done this way?"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scopeYesFile path, module name, or symbol to query

Implementation Reference

  • Registration of the `twining_why` tool in `src/tools/decision-tools.ts`.
    // twining_why — Retrieve decision chain for a scope or file
    server.registerTool(
      "twining_why",
      {
        description:
          'Retrieve all decisions affecting a given scope or file. Shows the decision chain with rationale, confidence, and alternatives count. Essential for understanding "why was it done this way?"',
        inputSchema: {
          scope: z
            .string()
            .describe("File path, module name, or symbol to query"),
        },
      },
      async (args) => {
        try {
          const result = await engine.why(args.scope);
          return toolResult(result);
        } catch (e) {
          return toolError(
            e instanceof Error ? e.message : "Unknown error",
            "INTERNAL_ERROR",
          );
        }
      },
    );
  • The implementation of the `why` method within the `DecisionEngine` class in `src/engine/decisions.ts`.
    /** Retrieve decision chain for a scope or file. */
    async why(scope: string): Promise<{
      decisions: Array<{
        id: string;
        summary: string;
        rationale: string;
        confidence: string;
        status: string;
        timestamp: string;
        alternatives_count: number;
        commit_hashes: string[];
      }>;
      active_count: number;
      provisional_count: number;
    }> {
      const decisions = await this.decisionStore.getByScope(scope);
    
      const mapped = decisions.map((d) => ({
        id: d.id,
        summary: d.summary,
        rationale: d.rationale,
        confidence: d.confidence,
        status: d.status,
        timestamp: d.timestamp,
        alternatives_count: d.alternatives.length,
        commit_hashes: d.commit_hashes ?? [],
      }));
    
      const active_count = decisions.filter((d) => d.status === "active").length;
      const provisional_count = decisions.filter(
        (d) => d.status === "provisional",
      ).length;
    
      return { decisions: mapped, active_count, provisional_count };
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions that the tool retrieves decisions and shows a decision chain with rationale, confidence, and alternatives count, which gives some insight into output behavior. However, it lacks critical details such as whether this is a read-only operation, potential rate limits, authentication requirements, error handling, or pagination. For a tool with no annotations, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and well-structured, consisting of two sentences that efficiently convey the tool's purpose and value. The first sentence explains what it does, and the second highlights its essential use case. There is no wasted language, and information is front-loaded, making it easy to understand quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (retrieving decision chains) and the absence of annotations and output schema, the description provides a basic understanding but lacks completeness. It explains the 'why' aspect and output elements (rationale, confidence, alternatives count), which is helpful. However, without annotations or output schema, it misses details on behavioral traits, return format, and error conditions, making it adequate but with clear gaps for effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the 'scope' parameter documented as 'File path, module name, or symbol to query'. The description adds no additional parameter semantics beyond what the schema provides, such as examples or constraints. Since schema coverage is high, the baseline score is 3, as the schema adequately handles parameter documentation without needing extra details in the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Retrieve all decisions affecting a given scope or file' with specific details about what it shows (decision chain, rationale, confidence, alternatives count). It distinguishes itself from siblings like 'twining_search_decisions' by focusing on the 'why' aspect, though it doesn't explicitly name alternatives. The verb 'retrieve' is specific, and the resource 'decisions' is well-defined.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by stating it's 'Essential for understanding "why was it done this way?"', which suggests it should be used for retrospective analysis of decisions. However, it doesn't provide explicit guidance on when to use this tool versus alternatives like 'twining_search_decisions' or 'twining_what_changed', nor does it mention any prerequisites or exclusions. The guidance is helpful but not comprehensive.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/daveangulo/twining-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server