Skip to content

fix(dialectic): pass custom_instructions to the dialectic prompt#906

Open
JoshKappler wants to merge 1 commit into
plastic-labs:mainfrom
JoshKappler:fix/dialectic-custom-instructions
Open

fix(dialectic): pass custom_instructions to the dialectic prompt#906
JoshKappler wants to merge 1 commit into
plastic-labs:mainfrom
JoshKappler:fix/dialectic-custom-instructions

Conversation

@JoshKappler

@JoshKappler JoshKappler commented Jul 13, 2026

Copy link
Copy Markdown

Fixes #874. The dialectic chat path calls get_configuration() but only reads peer_card.use from it, so workspace and session custom_instructions get dropped before the prompt is built. The deriver already honors that field, so instructions shaped how conclusions were written but had no effect on what the chat endpoint actually answered.

This threads custom_instructions through DialecticAgent into agent_system_prompt and renders a CUSTOM INSTRUCTIONS section following the deriver's pattern, on both the streaming and non-streaming paths. I built the section as a plain f-string rather than with cleandoc, since multi-line instructions drop the common margin to zero and would leave the surrounding block indented.

Tested with uv run pytest tests/dialectic (11 passed) and tests/routes/test_peers.py (45 passed), with ruff and basedpyright clean. The two new chat-level tests fail if the kwarg is removed from chat.py, and one of them pins session config overriding workspace config.

Summary by CodeRabbit

  • New Features

    • Added support for custom instructions in dialectic conversations.
    • Custom instructions can now be included in agent prompts and support multiline formatting.
    • Session-level instructions take precedence over workspace-level instructions.
  • Bug Fixes

    • Ensured configured custom instructions are consistently forwarded to conversations.
  • Tests

    • Added coverage for instruction rendering, omission, formatting, and configuration precedence.

The dialectic chat path fetched the resolved configuration but only ever
read peer_card.use from it, so workspace/session custom_instructions were
dropped before the prompt was built. The deriver already honors the same
field, which meant instructions shaped how conclusions were written but not
how the chat endpoint answered.

Thread custom_instructions through DialecticAgent into agent_system_prompt
and render it as a CUSTOM INSTRUCTIONS section, following the deriver's
pattern. The section is built as a plain f-string rather than with cleandoc,
since multi-line instructions drop the common margin to zero and would leave
the surrounding block indented.
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3d3f55f9-d4e0-49c7-858e-3ba3b8b4eff3

📥 Commits

Reviewing files that changed from the base of the PR and between c7c1597 and 60d23f6.

📒 Files selected for processing (4)
  • src/dialectic/chat.py
  • src/dialectic/core.py
  • src/dialectic/prompts.py
  • tests/dialectic/test_custom_instructions.py

Walkthrough

Dialectic chat now forwards workspace or session custom instructions into DialecticAgent, which includes normalized instructions in its initial system prompt when provided. Tests cover rendering, omission, multiline formatting, propagation, and session precedence.

Changes

Dialectic custom instructions

Layer / File(s) Summary
Render custom instructions
src/dialectic/prompts.py
Optional instructions are normalized and rendered in a conditional CUSTOM INSTRUCTIONS: prompt section.
Wire instructions through chat
src/dialectic/core.py, src/dialectic/chat.py
DialecticAgent accepts custom instructions, and both chat paths pass the configured value into the agent.
Validate rendering and precedence
tests/dialectic/test_custom_instructions.py
Tests cover prompt formatting, absent instructions, agent propagation, workspace forwarding, and session-level precedence.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: vvoruganti

Poem

A rabbit hops through prompts so bright,
With custom words tucked in just right.
Workspace whispers, sessions steer,
The dialectic now can hear.
Fluffy tests confirm the flight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly states the main change: threading custom_instructions into the dialectic prompt.
Linked Issues check ✅ Passed The PR implements the required plumbing from chat.py through DialecticAgent into agent_system_prompt for custom_instructions.
Out of Scope Changes check ✅ Passed All code and tests are directly related to propagating and rendering custom_instructions in the dialectic chat path.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@karaokedjodua

Copy link
Copy Markdown

Finn-loop review of 60d23f6

CI: not configured
Mergeability: clean (mergeStateStatus BLOCKED — stale branch-protection rule; see note)

Review

This PR threads custom_instructions from workspace/session configuration into the dialectic prompt, matching the pattern already used by the deriver. Previously, get_configuration() was called but only peer_card.use was consumed — custom instructions were silently dropped before the prompt was built. The fix touches both streaming and non-streaming paths.

1. Must fix before merge

  • [CI] No required checks are configured on the fix/dialectic-custom-instructions branch. Additionally, mergeStateStatus is BLOCKED while mergeable is MERGEABLE, indicating a stale branch-protection rule references a check that no longer exists or doesn't match. A repo admin must either add required CI or remove/update the stale rule before this can merge.

2. Should fix soon

None.

3. Safe to merge

Yes on code merits — the change is focused (4 files, ~30 lines of logic + 134 lines of thorough tests). Both chat paths are updated consistently with the deriver's pattern. Tests cover rendering, omission (None/empty/whitespace), multiline formatting, agent propagation, workspace forwarding, and session-vs-workspace precedence. No security concerns, no scope creep.

Labels to apply: needs-human-review, loop-approved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dialectic chat endpoint fetches but discards workspace custom_instructions

2 participants