Understanding model parameters helps you fine-tune agent behavior for optimal results.
Controls randomness in responses.
Low (0.0 - 0.3)
Medium (0.4 - 0.7) [Default]
High (0.8 - 2.0)
Examples:
Query: "Explain smart contract reentrancy"
Temperature 0.0:
"Reentrancy occurs when a function calls an external contract..."
[Same answer every time]
Temperature 0.7:
"Reentrancy is a vulnerability where..."
[Slight variations in phrasing]
Temperature 1.5:
"Picture this: your smart contract is like a bank vault..."
[Creative analogies, different approaches]
Alternative to temperature. Controls diversity by probability threshold.
How it works: Model generates candidate words with probabilities:
ethereum (40%)blockchain (30%)crypto (20%)web3 (10%)top_p = 0.9: Include top candidates until 90% cumulative probability → Considers: ethereum (40%) + blockchain (30%) + crypto (20%) = 90%
top_p = 0.5: Only top 50% → Considers: ethereum (40%) only
Settings:
⚠️ Don’t adjust both temperature AND top_p - use one or the other.
Penalizes words that already appeared, reducing repetition.
Negative (-2.0 to -0.1)
Zero (0.0) [Default]
Positive (0.1 to 2.0)
Example (explaining DeFi):
Presence Penalty = -1.0:
"DeFi protocols provide DeFi services. DeFi users can access DeFi platforms..."
[Repetitive, reinforces "DeFi"]
Presence Penalty = 0.0:
"DeFi protocols enable decentralized services. Users can access these platforms..."
[Natural repetition]
Presence Penalty = 1.5:
"Decentralized finance protocols enable trustless services. Participants can access blockchain-based platforms..."
[Varied vocabulary]
Penalizes words based on how OFTEN they’ve appeared.
Difference from Presence Penalty:
Negative (-2.0 to -0.1)
Zero (0.0) [Default]
Positive (0.1 to 2.0)
Example:
Frequency Penalty = -2.0:
"The yield yield yield yield optimizer optimizes yield yield..."
[Excessive repetition]
Frequency Penalty = 0.0:
"The yield optimizer analyzes yield opportunities and optimizes returns..."
[Natural]
Frequency Penalty = 2.0:
"The return optimizer analyzes APY opportunities and maximizes profits..."
[Varied terms]
low
medium [Default]
high
{
"frequency_penalty": 0.3,
"presence_penalty": 0.2,
"reasoning_effort": "medium",
"temperature": 0.3,
"top_p": 0.8
}
Consistent, factual, avoids repetition
{
"frequency_penalty": 0.6,
"presence_penalty": 0.5,
"reasoning_effort": "low",
"temperature": 0.9,
"top_p": 0.95
}
Diverse, creative, varied vocabulary
{
"frequency_penalty": 0.0,
"presence_penalty": 0.0,
"reasoning_effort": "high",
"temperature": 0.1,
"top_p": 0.9
}
Deterministic, precise, allows technical repetition
{
"frequency_penalty": 0.2,
"presence_penalty": 0.1,
"reasoning_effort": "high",
"temperature": 0.4,
"top_p": 0.85
}
Thorough, analytical, comprehensive
{
"frequency_penalty": 0.1,
"presence_penalty": 0.0,
"reasoning_effort": "medium",
"temperature": 0.2,
"top_p": 0.8
}
Consistent, reliable, factual
Begin with default/low values, then increase gradually:
Change ONE parameter at a time to understand its effect.
Track across multiple queries:
Temperature + Top P
Presence + Frequency Penalties
Reasoning Effort + Temperature
Max Tokens Not a tuning parameter, but important:
Models:
For agents, set based on expected output:
Problem: Too random/inconsistent → Decrease temperature (try 0.3) → Decrease top_p (try 0.8)
Problem: Too repetitive → Increase presence_penalty (0.5-1.0) → Increase frequency_penalty (0.5-1.0)
Problem: Too boring/generic → Increase temperature (0.7-1.0) → Increase top_p (0.95)
Problem: Off-topic responses → Decrease temperature → Improve system prompt clarity
Problem: Too brief → Check max_tokens → Adjust prompt to request detail
Problem: Too verbose → Increase frequency_penalty → Add “be concise” to system prompt
Experiment and iterate - optimal settings vary by use case and agent personality.