System Prompts
Learn how to craft effective system prompts that define your agent's personality, behavior, and approach to tasks.
Recommended: Keep prompts in Markdown files
Store prompts in versioned .md
files. This keeps code clean, enables easy edits and reviews, and works across tools.
- Readable and diff-friendly
- Reusable across multiple agents
- Simple to test and iterate
1prompts/
2 assistant.md
3 expert/
4 researcher.md
5
1# Assistant
2You are a helpful, concise assistant. When answering:
3
4- Be direct and use simple language
5- Prefer bullet points over long paragraphs
6- Ask one clarifying question if necessary before acting
7
8Output format:
9- Start with a one-sentence summary
10- Then provide numbered steps if applicable
11
1from connectonion import Agent
2
3agent = Agent(
4 name="assistant",
5 system_prompt="prompts/assistant.md", # Recommended: Markdown file
6 tools=[...]
7)
8
9print(agent.input("Summarize the key points of our meeting notes."))
Avoid embedding large prompt strings directly in code. It makes diffs noisy and complicates collaboration. Prefer .md
files and reference them from your agent.
Quick Start
ConnectOnion offers three ways to provide system prompts. We recommend Markdown files.
Markdown File (Recommended)
Store prompts in prompts/*.md
and reference by path. Best for collaboration, reviews, and reuse.
Path Object
Use pathlib.Path
when you need explicit file existence checks.
Direct String (for quick demos)
Acceptable for tiny demos or notebooks, but keep production prompts in Markdown files.
1from connectonion import Agent
2
3# Method 1 (Recommended): Load from Markdown file
4agent = Agent(
5 name="expert",
6 system_prompt="prompts/expert.md", # Versioned prompt content
7 tools=[...]
8)
9
10# Method 2: Path object
11from pathlib import Path
12agent = Agent(
13 name="specialist",
14 system_prompt=Path("prompts/specialist.txt"),
15 tools=[...]
16)
Iteration Control (max_iterations)
You can set a default iteration limit on the agent, and still override it for specific tasks.
1from connectonion import Agent
2
3# Set a global limit for this agent
4agent = Agent(
5 name="helper",
6 system_prompt="You are precise and concise.",
7 tools=[...],
8 max_iterations=15 # default limit for this agent
9)
10
11# For one-off complex tasks, override per call
12result = agent.input(
13 "Plan a 3-step workflow using the available tools",
14 max_iterations=25
15)
Supported File Formats
Markdown
Human-readable, structured prompts
YAML
Structured data with metadata
JSON
Machine-readable with schemas
Plain Text
Simple text prompts
No Extension
Any text file works