Skip to content

Problem with Pi's prompt template argument parsing #4553

@parijatmishra

Description

@parijatmishra

What happened?

Pi's argument parsing for prompt-templates seems to be broken. Pi docs: https://pi.dev/docs/latest/prompt-templates#arguments I want to create a custom prompt (say arg-test), and use it like this:

/arg-test short-label

Verbose description...

Expected:

  • $1: "short-label"
  • ${@:2}: Verbose description ...

What I get:

  • $1: "short-label"
  • ${@:2}: description ....

Info:

  • Pi: 0.74.0
  • Node: v26.1.0
  • OS: macos Tahoe

Steps to reproduce

Prompt Template

File: .pi/prompts/arg-test.md:

---
description: test pi's prompt template argument substitution
---

Parse the name-value pairs below, and return the names and values back.

- arg1: $1
- rest: ${@:2}

Test 1 (passes)

Prompt in CLI:

/arg-test label-1 Here is some description #1.

Wire-request (JSON) snippet:

    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Parse the name-value pairs below, and return the names and values back.\n\n- arg1: label-1\n- rest: Here is some description #1."
        }
      ]
    }

CLI shows input:

Parse the name-value pairs below, and return the names and values back.

 - arg1: label-1
 - rest: Here is some description #1.

CLI shows output:


 Here are the parsed name-value pairs:

 ┌──────┬──────────────────────────────┐
 │ Name │ Value                        │
 ├──────┼──────────────────────────────┤
 │ arg1 │ label-1                      │
 ├──────┼──────────────────────────────┤
 │ rest │ Here is some description #1. │
 └──────┴──────────────────────────────┘

Test 2 (fails)

Prompt in CLI:

/arg-test label-2

Here is some description #2.

CLI shows input:


 Parse the name-value pairs below, and return the names and values back.

 - arg1: label-2

 Here
 - rest: is some description #2.

Wire-request (JSON) snippet:

    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Parse the name-value pairs below, and return the names and values back.\n\n- arg1: label-2\n\nHere\n- rest: is some description #2."
        }
      ]
    }

CLI shows output:


 Here are the parsed name-value pairs:

 ┌──────┬─────────────────────────┐
 │ Name │ Value                   │
 ├──────┼─────────────────────────┤
 │ arg1 │ label-2                 │
 ├──────┼─────────────────────────┤
 │ rest │ is some description #2. │
 └──────┴─────────────────────────┘

Expected behavior

In Test 2, I expect the CLI to convert my prompt to the input:


 Parse the name-value pairs below, and return the names and values back.

 - arg1: label-2
 - rest:  Here is some description #2.

Version

0.74.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions