The problem with prompts
A prompt used a few times in a conversation is fine, but plugged into a process and run dozens or hundreds of times a day, problems appear:
- The same input gives different results at different times
- The output format varies, and programs cannot consume it
- When something fails, you cannot tell which step failed
- When someone else takes over, they cannot tell what the prompt is doing
Making it a function: four elements
- Input: fixed fields (text, files, parameters)
- Steps: how many processing blocks, and what each does
- Output: a fixed structure and format
- Tests: a set of repeatable cases
Write these four down and the prompt becomes a component rather than a paragraph.
How to design inputs
- Fewer fields rather than more; every field must have a use
- Separate long text from short parameters
- Give defaults so missing values do not raise errors
- State clearly what happens when there is no data
How to split the steps
- Understand first (extract points, classify)
- Then process (calculate, judge, generate)
- Finally validate (format, facts, boundaries)
- Every step can be run and checked on its own
How to define the output
- Use a fixed structure (JSON, fixed fields)
- Specify the value range and how empty values are written
- When uncertain, output “unknown” instead of making things up
- Include the basis or source in the output
How to test
- Normal cases: typical inputs
- Boundary cases: empty values, very long input, special characters
- Failure cases: missing fields, contradictory data
- Stability: run the same input three times and see whether the conclusion is consistent
The pass rate does not need to be 100% at the start, but it must be continuously observed and gradually improved.
How to use the tools
Visual platforms (tools like Palantir AIP Logic) provide:
- An orchestration interface for inputs / blocks / outputs
- A debugger: see the model’s reasoning and intermediate results at each step
- A run panel: single runs and unit tests
- Evaluation: run a test set in batches and check the pass rate
The core is not the tool but the structure of “input — steps — output — tests”.
When to make it a function
- The same task will be repeated many times
- It needs to be embedded in a process (auto-process a submitted form, run on a schedule)
- Others need to be able to use and maintain it
- Results need to be traceable and acceptable
Checklist
- Input fields are fixed and have defaults
- Steps are split into separately checkable blocks
- The output format is fixed, including unknown handling
- There are normal / boundary / failure test cases
- The same input gives stable results across runs
- Errors can be traced to a specific step
- There is version history and changes can be rolled back
Reference: key points adapted from Palantir’s official documentation “AIP Logic: Getting started” and “AIP Evals”, rewritten for general tools and practical use.
Questions
What is the difference from just writing a prompt?
A prompt is a one-off conversation; a function has fixed inputs, a fixed output format, is repeatable and testable. Use functions for stable reuse and embedding in processes, prompts for ad-hoc questions.
Can I build one without a programming background?
You can build with visual tools: define inputs, drag in processing blocks, specify the output format, then validate with a test set. The core is not writing code but thinking the steps and acceptance through.
How do I know an AI function is usable?
Give it a fixed set of test cases (normal, boundary, failure) and check whether the pass rate is stable; run the same input several times to see whether the result is consistent; and check whether an error can be traced to a specific step.