Skip to content

LLM Output Not Flushed to File Before MCP Execution in GenAIScript #1809

@lemmy

Description

@lemmy

When running the following script, it appears that GenAIScript does not serialize the LLM's output (i.e., the generated specification) to the output file before invoking the MCP server. As a result, the MCP receives no input, and the MCP process fails to execute as expected.

script({
    files: "puzzles/SomePuzzle.md"
})

defTool({
    tla: {
        url: "http://localhost:59071/mcp",
        type: "http"
    }
})

const file = env.files[0];
const baseName = file.filename.replace(/\.[^.]*$/, '');
const fileName = baseName.split('/').pop();
defFileOutput(fileName + ".tla", "the created TLA+ specification")

$`Formalize the puzzle ${file.filename} using TLA+: Create a TLA+ specification that captures the problem's requirements and constraints. Use the TLC model checker via the tla_tlaplus_mcp_sany_parse to parse the specification. If parsing fails, you will need to fix the specification and try again.`

Json schema of this particular MCP server, formalizing that the MCP requires a fully-qualified filename as input:

  {
    "name": "tlaplus_mcp_sany_parse",
    "description": "Parse the input TLA+ module using SANY from the TLA+ tools. Use SANY to perform syntax and level-checking of the module. Ensure that the input is provided as a fully qualified file path, as required by the tool.",
    "inputSchema": {
      "type": "object",
      "properties": {
        "fileName": {
          "type": "string",
          "description": "The full path to the file containing the TLA+ module."
        }
      },
      "required": [
        "fileName"
      ],
      "additionalProperties": false,
      "$schema": "http://json-schema.org/draft-07/schema#"
    }
  },

The expected behavior is for the generated .tla file (containing the TLA+ specification) to be written before the MCP server gets invoked. How can we force GenAIScript to flush or persist the LLM's output to the/a target file before invoking the MCP tool?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions