Persistent project rules with RulesConfig and AGENTS.md

Load team standards automatically from AGENTS.md

Copy-pasting the same 30 lines of coding or compliance rules into every script drifts quickly. Put shared rules in AGENTS.md and load them cleanly with RulesConfig(files=[…], char_budget=…).

Run this example to write a temporary AGENTS.md rule file, bind it to an Agent via RulesConfig, and execute a real query.

Example

import tempfile
from pathlib import Path
from praisonai import Agent, RulesConfig

with tempfile.TemporaryDirectory() as tmp:
    rules_file = Path(tmp) / 'AGENTS.md'
    rules_file.write_text('# Rules\n- Always prefix answers with [POLICY-OK].\n')
    rules_cfg = RulesConfig(files=[str(rules_file)], char_budget=2000, workspace_path=tmp)
    agent = Agent(
        name='PolicyAgent',
        instructions='Follow workspace rules strictly and answer in one sentence.',
        rules=rules_cfg,
        output='silent',
    )
    print('Rule budget:', rules_cfg.char_budget)
    print('Reply      :', agent.start('Confirm our support hours are 9-5 UTC.'))

Try it Yourself

Example explained

  • RulesConfig(files=[…], char_budget=2000) — Injects project rules from disk while capping prompt token overhead at 2,000 characters.
  • rules=rules_cfg — Attaches persistent repo governance directly to the Agent.

Why char_budget matters in large repositories

Without a char_budget, oversized documentation files accidentally placed in rule folders can silently consume half your context window and spike per-call cost.

Common pitfall: putting trust/security credentials in repo rules

AGENTS.md is great for style, naming, and workflow conventions — never store API keys or auto-approve security overrides inside a shared git repository file.

Reference: documentation