Skip to content

fix: add per-platform DisplayPolicy with layered resolver#2488

Merged
MervinPraison merged 2 commits into
mainfrom
claude/issue-2487-20260630-0944
Jun 30, 2026
Merged

fix: add per-platform DisplayPolicy with layered resolver#2488
MervinPraison merged 2 commits into
mainfrom
claude/issue-2487-20260630-0944

Conversation

@praisonai-triage-agent

@praisonai-triage-agent praisonai-triage-agent Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Fixes #2487

Summary

Adds a single, reusable per-platform display/verbosity policy to the core SDK with a predictable layering.

  • New DisplayPolicy dataclass in praisonaiagents/bots/config.py covering:
    • streaming (off / draft / progress)
    • tool_progress (off / inline)
    • interim_assistant_messages (bool)
    • footer (off / compact)
  • New resolve_display_policy(platform, config) resolver with precedence:
    explicit display.platforms.<platform>.<setting> β†’ display.<setting> global β†’ platform-tier default β†’ built-in default
  • Built-in platform tiers (edit / work / noedit / batch) so most operators configure nothing and still get correct UX per channel (Telegram streams, Slack posts discrete progress, Email/SMS send one final message).
  • Exported DisplayPolicy and resolve_display_policy from praisonaiagents.bots.

Routing

  • Core β€” config/contract only, no heavy deps, sits beside bots/config.py. The wrapper (bots/_streaming.py/adapters) only reads the resolved policy.
  • No Agent class changes, no new dependencies, no __init__ name collisions.
  • Fully backward-compatible (new optional dataclass + resolver).

Tests

Added TestDisplayPolicy to tests/unit/test_bots.py (defaults, round-trip, invalid-value coercion, tier defaults, and full 4-layer precedence). All 32 tests in test_bots.py pass.

Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added configurable display behavior for bots, including options for streaming, tool progress, interim messages, and footer visibility.
    • Introduced platform-based default display settings with support for overriding behavior at different configuration levels.
    • Made the new display policy settings available for use throughout the app.
  • Tests

    • Added coverage for default values, configuration round-tripping, platform-specific defaults, and override precedence.

Adds a DisplayPolicy config dataclass and resolve_display_policy resolver
to praisonaiagents/bots/config.py covering streaming, tool_progress,
interim_assistant_messages and footer, with precedence:
explicit platform override > global default > platform-tier default > built-in.

Co-authored-by: MervinPraison <454862+MervinPraison@users.noreply.github.com>
@MervinPraison

Copy link
Copy Markdown
Owner

@coderabbitai review

@MervinPraison

Copy link
Copy Markdown
Owner

/review

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more β†’

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account β†’

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us β†’

@MervinPraison MervinPraison added pipeline/blocked:ci Blocked: CI not green on HEAD pipeline/blocked:no-final Blocked: no FINAL @claude trigger yet pipeline/final-claude-pending Reviews done; waiting for FINAL @claude labels Jun 30, 2026
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor
βœ… Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e1f7e1ef-a49d-4bf8-8cb7-a5c9bbca701e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • πŸ” Trigger review
πŸ“ Walkthrough

Walkthrough

Adds a DisplayPolicy dataclass to praisonaiagents/bots/config.py with streaming, tool_progress, interim_assistant_messages, and footer fields, plus built-in per-tier defaults and a resolve_display_policy resolver that layers explicit platform overrides β†’ global display defaults β†’ platform-tier defaults β†’ built-in defaults. Both names are exported from the bots package and covered by a new TestDisplayPolicy test class.

Changes

Per-platform DisplayPolicy system

Layer / File(s) Summary
DisplayPolicy dataclass, tier defaults, and resolver
src/praisonai-agents/praisonaiagents/bots/config.py
Defines DisplayPolicy with four fields, to_dict/from_dict with coercion, _TIER_DEFAULTS for edit/work/noedit/batch tiers, and resolve_display_policy with _extract_display/_merge_policy helpers implementing layered precedence.
Package exports and unit tests
src/praisonai-agents/praisonaiagents/bots/__init__.py, src/praisonai-agents/tests/unit/test_bots.py
Adds DisplayPolicy and resolve_display_policy to the bots package imports and __all__; adds TestDisplayPolicy covering defaults, dict round-trip, invalid-value coercion, tier defaults per platform, and multi-layer precedence.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

πŸ‡ A policy for every chat,
Telegram streams, Slack prefers flat,
Email sends one tidy note,
Footer off β€” no need to gloat.
Layered defaults, neat and true,
The rabbit ships clean UX through! ✨

πŸš₯ 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 summarizes the main change: adding a per-platform DisplayPolicy with layered resolution.
Linked Issues check βœ… Passed The changes add DisplayPolicy, layered resolution, exports, and tests that match the requested per-platform display policy and precedence.
Out of Scope Changes check βœ… Passed The patch stays focused on the display-policy config layer and its tests, with no unrelated feature additions.
Docstring Coverage βœ… Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/issue-2487-20260630-0944

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.

@MervinPraison

Copy link
Copy Markdown
Owner

@copilot Do a thorough review of this PR. Read ALL existing reviewer comments above from Qodo, Coderabbit, and Gemini first β€” incorporate their findings.

Review areas:

  1. Bloat check: Are changes minimal and focused? Any unnecessary code or scope creep?
  2. Security: Any hardcoded secrets, unsafe eval/exec, missing input validation?
  3. Performance: Any module-level heavy imports? Hot-path regressions?
  4. Tests: Are tests included? Do they cover the changes adequately?
  5. Backward compat: Any public API changes without deprecation?
  6. Code quality: DRY violations, naming conventions, error handling?
  7. Address reviewer feedback: If Qodo, Coderabbit, or Gemini flagged valid issues, include them in your review
  8. Suggest specific improvements with code examples where possible

@greptile-apps

greptile-apps Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a reusable display policy resolver for bot platforms. The main changes are:

  • New DisplayPolicy settings for streaming, tool progress, interim messages, and footers.
  • Layered policy resolution from platform overrides, global display settings, platform tiers, and built-in defaults.
  • Bot package exports for the new policy type and resolver.
  • Unit tests for defaults, coercion, platform lookup, and precedence.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
src/praisonai-agents/praisonaiagents/bots/config.py Adds the display policy model, layered resolver, value coercion, platform tiers, and platform override lookup.
src/praisonai-agents/praisonaiagents/bots/init.py Exports the new display policy model and resolver from the bots package.
src/praisonai-agents/tests/unit/test_bots.py Adds tests for display policy defaults, coercion, platform defaults, and override precedence.

Reviews (2): Last reviewed commit: "fix: robust bool/platform-key parsing in..." | Re-trigger Greptile

Comment thread src/praisonai-agents/praisonaiagents/bots/config.py
Comment thread src/praisonai-agents/praisonaiagents/bots/config.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

πŸ€– Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/praisonai-agents/praisonaiagents/bots/config.py`:
- Around line 275-277: The interim_assistant_messages assignment in the config
parsing logic is using bool(...) on raw input, which will incorrectly treat
non-empty strings like "false" or "0" as True. Update the configuration handling
in the relevant parser/build method to explicitly accept real boolean values for
interim_assistant_messages and otherwise fall back to
base.interim_assistant_messages (or a safe default) when the input is not
already a boolean.

In `@src/praisonai-agents/tests/unit/test_bots.py`:
- Around line 71-72: Add a real end-to-end agentic test for this feature in the
existing test suite, not just unit coverage. Use the TestDisplayPolicy area in
test_bots.py as the place to add a test that exercises the actual LLM-backed
agent flow through the relevant bot/policy path, and verify the behavior by
running the agent end-to-end rather than mocking the core LLM interaction. Keep
the test aligned with the repo’s agentic testing pattern so it validates the
feature in a real execution path.
πŸͺ„ Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 46ea2ef7-eff1-426b-8e55-75696aa9c454

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between ac55fd9 and c395c3f.

πŸ“’ Files selected for processing (3)
  • src/praisonai-agents/praisonaiagents/bots/__init__.py
  • src/praisonai-agents/praisonaiagents/bots/config.py
  • src/praisonai-agents/tests/unit/test_bots.py

Comment on lines +275 to +277
interim_assistant_messages=bool(
data.get("interim_assistant_messages", base.interim_assistant_messages)
),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟑 Minor | ⚑ Quick win

Don't coerce string booleans with bool(...).

bool("false") and bool("0") both evaluate to True, so a text-backed config can silently flip interim_assistant_messages on instead of preserving the operator's intent. Parse actual booleans explicitly here, or fall back to the default for non-boolean input.

πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/praisonai-agents/praisonaiagents/bots/config.py` around lines 275 - 277,
The interim_assistant_messages assignment in the config parsing logic is using
bool(...) on raw input, which will incorrectly treat non-empty strings like
"false" or "0" as True. Update the configuration handling in the relevant
parser/build method to explicitly accept real boolean values for
interim_assistant_messages and otherwise fall back to
base.interim_assistant_messages (or a safe default) when the input is not
already a boolean.

Comment on lines +71 to +72
class TestDisplayPolicy:
"""Tests for DisplayPolicy and resolve_display_policy."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ“ Maintainability & Code Quality | 🟠 Major | πŸ—οΈ Heavy lift

Add the required end-to-end agentic coverage for this feature.

These unit tests are good, but this change set still doesn't include the real LLM-backed agentic test the repo requires for every new feature. As per coding guidelines, "Every feature must include a real agentic test where the agent actually calls the LLM end-to-end, not just smoke tests."

πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/praisonai-agents/tests/unit/test_bots.py` around lines 71 - 72, Add a
real end-to-end agentic test for this feature in the existing test suite, not
just unit coverage. Use the TestDisplayPolicy area in test_bots.py as the place
to add a test that exercises the actual LLM-backed agent flow through the
relevant bot/policy path, and verify the behavior by running the agent
end-to-end rather than mocking the core LLM interaction. Keep the test aligned
with the repo’s agentic testing pattern so it validates the feature in a real
execution path.

Source: Coding guidelines

@MervinPraison

Copy link
Copy Markdown
Owner

@claude You are the FINAL architecture reviewer. If the branch is under MervinPraison/PraisonAI (not a fork), you are able to make modifications to this branch and push directly. SCOPE: Focus ONLY on Python packages (praisonaiagents, praisonai). Do NOT modify praisonai-rust or praisonai-ts. Read ALL comments above from Gemini, Qodo, CodeRabbit, and Copilot carefully before responding.

Phase 1: Review per AGENTS.md

  1. Protocol-driven: check heavy implementations vs core SDK
  2. Backward compatible: ensure zero feature regressions
  3. Performance: no hot-path regressions
  4. SDK value: review in depth whether the change genuinely adds value to the SDK β€” never add features for the sake of adding them. It must strengthen the SDK (simpler, more user-friendly, robust, world-class, secure). If it does not clearly add value, request changes or recommend rejecting/closing rather than merging scope creep
  5. Do not bloat the Agent class with additional params β€” only if absolutely required; we already support many params.

Phase 2: FIX Valid Issues
5. For any VALID bugs or architectural flaws found by Gemini, CodeRabbit, Qodo, Copilot, or any other reviewer: implement the fix
6. Push all code fixes directly to THIS branch (do NOT create a new PR)
7. Comment a summary of exact files modified and what you skipped

Phase 3: Final Verdict
8. If all issues are resolved, approve the PR / close the Issue
9. If blocking issues remain, request changes / leave clear action items

@MervinPraison MervinPraison added pipeline/awaiting-merge-gate FINAL done; waiting for merge gate / CI pipeline/blocked:cooldown Blocked: post-push or @claude cooldown and removed pipeline/final-claude-pending Reviews done; waiting for FINAL @claude pipeline/blocked:no-final Blocked: no FINAL @claude trigger yet labels Jun 30, 2026
@praisonai-triage-agent

praisonai-triage-agent Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

Claude finished @MervinPraison's task β€”β€” View job


Final Architecture Review β€” PR #2488 βœ… APPROVED

Read all reviewer comments (Greptile, CodeRabbit, Qodo, Copilot). Fixed the valid bugs and pushed directly to this branch.

Phase 1 β€” Architecture (per AGENTS.md): PASS

Check Verdict
Protocol-driven / routing βœ… Config-only in core (bots/config.py), no heavy deps, lazy-safe
Agent class bloat βœ… Zero new Agent params
Backward compatible βœ… New optional dataclass + resolver; no regressions
Performance βœ… No module-level heavy imports, not on hot path
SDK value βœ… Genuine β€” one reusable, predictable layered policy replaces ad-hoc per-channel verbosity logic
__init__ name collision βœ… None

Phase 2 β€” Fixes pushed (commit 346778334)

Files modified:

  • src/praisonai-agents/praisonaiagents/bots/config.py
    • Fix Github actions fixΒ #1 (Greptile P1 + CodeRabbit): bool("false") returned True, silently flipping interim_assistant_messages on for YAML/JSON/env string configs. Added _coerce_bool (true/1/yes/on, false/0/no/off, case-insensitive; non-bool falls back to default). Real booleans pass through.
    • Fix Merge pull request #1 from MervinPraison/developΒ #2 (Greptile P2): mixed-case platform keys ({Telegram: {...}}) were skipped. Added _lookup_platform with exact β†’ lower β†’ case-insensitive scan so explicit platform overrides keep highest precedence.
  • src/praisonai-agents/tests/unit/test_bots.py
    • test_from_dict_string_booleans (string/garbage/real-bool coercion)
    • test_platform_override_case_insensitive

Skipped (with reason):

  • CodeRabbit "add a real LLM-backed agentic test" β€” N/A. DisplayPolicy/resolve_display_policy are pure config functions with no LLM call. An end-to-end LLM test adds cost/flakiness with zero coverage gain; deterministic unit tests are correct here.
  • Qodo review was paused (not actionable). Copilot review not present in thread.

Tests: 34 passed (32 original + 2 new) in 0.24s.

Verdict: βœ… Approved β€” all valid reviewer issues resolved, no blocking issues remain.

Job run Β· Branch

- Parse string booleans (e.g. "false"/"0") for interim_assistant_messages
  instead of bool(...) which treated any non-empty string as True
- Match platform override keys case-insensitively so natural keys
  like {Telegram: {...}} apply when resolving "telegram"
- Add tests for both cases

Co-authored-by: Mervin Praison <MervinPraison@users.noreply.github.com>
@MervinPraison

Copy link
Copy Markdown
Owner

@claude You are the FINAL architecture reviewer. If the branch is under MervinPraison/PraisonAI (not a fork), you are able to make modifications to this branch and push directly. SCOPE: Focus ONLY on Python packages (praisonaiagents, praisonai). Do NOT modify praisonai-rust or praisonai-ts. Read ALL comments above from Gemini, Qodo, CodeRabbit, and Copilot carefully before responding.

Phase 1: Review per AGENTS.md

  1. Protocol-driven: check heavy implementations vs core SDK
  2. Backward compatible: ensure zero feature regressions
  3. Performance: no hot-path regressions
  4. SDK value: review in depth whether the change genuinely adds value to the SDK β€” never add features for the sake of adding them. It must strengthen the SDK (simpler, more user-friendly, robust, world-class, secure). If it does not clearly add value, request changes or recommend rejecting/closing rather than merging scope creep
  5. Do not bloat the Agent class with additional params β€” only if absolutely required; we already support many params.

Phase 2: FIX Valid Issues
5. For any VALID bugs or architectural flaws found by Gemini, CodeRabbit, Qodo, Copilot, or any other reviewer: implement the fix
6. Push all code fixes directly to THIS branch (do NOT create a new PR)
7. Comment a summary of exact files modified and what you skipped

Phase 3: Final Verdict
8. If all issues are resolved, approve the PR / close the Issue
9. If blocking issues remain, request changes / leave clear action items

@praisonai-triage-agent

praisonai-triage-agent Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

Claude finished @MervinPraison's task β€”β€” View job


Final Architecture Review β€” PR #2488 βœ… APPROVED

Read all reviewer comments (Greptile, CodeRabbit, Qodo, Copilot). Verified the branch state β€” both valid bugs were already fixed and pushed in commit 346778334. Working tree is clean; no further code changes were required this round.

  • Read AGENTS.md guidelines
  • Review config.py (DisplayPolicy + resolver)
  • Verify prior fixes (bool coercion, mixed-case platform keys)
  • Architecture validation per AGENTS.md
  • Run tests β€” 34 passed in 0.22s
  • Final verdict

Phase 1 β€” Architecture (per AGENTS.md): PASS

Check Verdict
Protocol-driven / routing βœ… Config-only in core (bots/config.py), no heavy deps, no I/O
Agent class bloat βœ… Zero new Agent params
Backward compatible βœ… New optional dataclass + pure resolver; no regressions
Performance βœ… No module-level heavy imports; not on hot path
SDK value βœ… Genuine β€” one reusable layered policy replaces ad-hoc per-channel verbosity logic
__init__ collision βœ… None β€” DisplayPolicy / resolve_display_policy cleanly exported

Phase 2 β€” Reviewer issues

Both valid bugs are already resolved in config.py:

  1. String-boolean coercion (Greptile P1 + CodeRabbit): from_dict now routes interim_assistant_messages through _coerce_bool (config.py:318). "false"/"0" β†’ False, garbage β†’ default, real bools pass through. No more bool("false") is True footgun.
  2. Mixed-case platform keys (Greptile P2): resolve_display_policy now uses _lookup_platform (config.py:379) with exact β†’ lower β†’ case-insensitive scan, so {platforms: {Telegram: …}} matches telegram and keeps highest precedence.

Covered by test_from_dict_string_booleans and test_platform_override_case_insensitive in tests/unit/test_bots.py.

Skipped (with reason):

  • CodeRabbit "add a real LLM-backed end-to-end agentic test" β€” N/A. DisplayPolicy/resolve_display_policy are pure config functions with no LLM call anywhere in the path. An e2e LLM test would add cost/flakiness for zero coverage gain; deterministic unit tests are the correct fit.
  • Qodo β€” review paused (not actionable). Copilot β€” no review content present in thread.

Phase 3 β€” Verdict: βœ… Approved

All valid reviewer issues are resolved, architecture is sound, and 34 passed. No blocking issues remain. Note: I cannot formally approve via GitHub review (security restriction), but this is my recommendation to merge.

Job run Β· Branch

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

Labels

pipeline/awaiting-merge-gate FINAL done; waiting for merge gate / CI pipeline/blocked:ci Blocked: CI not green on HEAD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No per-platform display/verbosity policy β€” output behaviour (streaming, tool-progress, footer) can't be tuned per channel with layered config

1 participant