Implement prompt composition with conventions

t-396·WorkTask·
·
·
Created1 month ago·Updated1 month ago

Description

Edit

Add a Compose operation to the free monad that combines prompts with predictable semantics.

Approach

Define conventions for how prompts combine, making composition predictable even without full Bayesian theory.

Conventions to Define

1. System prompt = hyperprior (sets the space of behaviors) 2. Skills = conditional priors (activated by context) 3. User messages = observations (data that updates the posterior) 4. Assistant messages = posterior samples (past behavior conditions future)

Implementation

1. Add Compose constructor to OpF 2. Define PromptComponent type (System | Skill | Message | Context) 3. Composition rules:

  • System prompts: last one wins? merge?
  • Skills: concatenate with separators
  • Context: append in order

4. Verify: composed prompt behaves as expected

Metrics & Verification

  • Predictability: does compose(A, B) behave as expected from A and B alone?
  • No interference: adding B doesn't break A's behavior
  • Order sensitivity: document when order matters

Test Cases

  • Compose two skills -> agent has both capabilities
  • Compose base + override -> override takes precedence
  • Compose context chunks -> coherent understanding

Notes

This is conventions, not calculus. The goal is predictable engineering, not mathematical composition laws. But conventions can evolve toward theory.

Timeline (0)

No activity yet.