[Feature]: DSPY integration
DSPy Integration (Simple)
Goal:
Make every Bindu agent improve itself over time — safely.
The idea (one simple flow)
-
Users give feedback
Each agent response can be rated (⭐ 1–5 or good / bad). -
Feedback is stored
All interactions and ratings are stored in Postgres. -
Create a golden dataset
A script reads Postgres and selects the best-rated interactions.
These become the golden dataset. -
DSPy improves the prompt
DSPy reads the golden dataset and generates improved prompt suggestions
(better instructions, clearer examples, fewer mistakes). -
Deploy safely (canary style)
The new prompt is deployed alongside the old one.
Traffic is split using a ratio:- 90% → old prompt
- 10% → new prompt
-
Promote or roll back
If the new prompt performs better, increase traffic.
If not, instantly roll back.
What this enables
- Prompts improve using real user feedback
- No manual prompt tweaking in production
- Changes are measurable, reversible, and safe
- Works with existing Bindu agents and handlers
Mental model
Users rate → data improves → prompts evolve → traffic shifts
Bindu is the feedback loop.
DSPy is the optimizer.
Routing keeps everything safe.
What Bindu owns
- Interaction + feedback storage (Postgres)
- Golden dataset generation
- Prompt versioning
- Traffic routing (old vs new)
- Instant rollback
DSPy is simply the optimization engine in the middle.
Hey @raahulrahl , I've created a data flow chart to visualize how will the self improving agent will look like. Let me know your thoughts so that I can start implementing it.
-
USER SENDS MESSAGE POST / → {"method": "message/send", "params": {"message": "Write a poem"}}
-
TASK CREATED tasks table: {id: "task-1", history: [{role: "user", text: "Write a poem"}]}
-
WORKER SELECTS PROMPT (Canary Routing) _select_prompt_version() → weighted random → selects v1 (90%) or v2 (10%)
-
WORKER STORES PROMPT VERSION IN TASK UPDATE tasks SET metadata = {"prompt_version_id": 1} WHERE id = "task-1"
-
AGENT EXECUTES WITH SELECTED PROMPT message_history = [{"role": "system", "content": prompt_v1}] + user_messages response = manifest.run(message_history)
-
TASK COMPLETED UPDATE tasks SET state = "completed", history = [..., {role: "agent", text: "Here is your poem..."}]
-
USER RATES RESPONSE POST / → {"method": "tasks/feedback", "params": {"task_id": "task-1", "rating": 4}}
-
FEEDBACK STORED WITH PROMPT VERSION INSERT INTO task_feedback (task_id, feedback_data, prompt_version_id) VALUES ("task-1", {"rating": 4, ...}, 1)
-
ADMIN RUNS OPTIMIZATION (after 50+ ratings) $ bindu optimize-prompts --canary-weight 10
-
DSPY BUILDS GOLDEN DATASET SELECT tasks.history, feedback.rating FROM tasks JOIN task_feedback ON ... WHERE rating >= 4
-
DSPY OPTIMIZES PROMPT MIPROv2.compile() → analyzes patterns → generates improved prompt
-
NEW VERSION CREATED INSERT INTO prompt_versions (version, content, traffic_weight) VALUES ("dspy-20251217", "Improved prompt...", 10.0)
-
TRAFFIC SPLITS Now: 90% requests use v1, 10% use v2 (the optimized one)
-
FEEDBACK CONTINUES Users rate v2 responses → stored with prompt_version_id = 2
-
IF V2 PERFORMS BETTER $ bindu prompts promote v2 → v2 becomes 100%, v1 becomes 0%
-
IF V2 PERFORMS WORSE $ bindu rollback-prompt -v v1 → instant rollback to v1 at 100%
hi @zaiddkhan - some contributors are working on it - please join the channel and then @dspy-integrations
Hi @raahulrahl
I went through the DSPy integration proposal and the data flow shared above — really like the canary + rollback design.
I understand this is already in progress and coordinated. I’d love to contribute in a scoped way if helpful — for example:
- DSPy optimization script (golden dataset → prompt),
- prompt version performance metrics,
- or a small CLI command / docs around the workflow.
Please let me know what would be most useful and where I should coordinate (channel / thread). Happy to follow existing direction.
Hi @Anusha0501
I’m currently working on this issue. If you’d like to contribute, please message me in the #dspy-integration channel on Discord. I can then assign you a few scoped tasks related to this work.
You’ll find the Discord link in the README.
@Avngrstark62 can you please tell me what is the current status now - and what should be the reoadmap?
@raahulrahl The basic version of the end to end pipeline is almost ready. Currently we are only supporting the SIMBA optimizer. Also, The canary part is very simple now, we can make it more robust and efficient. I have assigned a contributor to add GEPA optimizer too. Also, we can assign someone to enhance the canary part or we can do this enhancement in the next version.
@raahulrahl please review PR #358 when you have time