defi-agents

Model Parameters Guide

Understanding model parameters helps you fine-tune agent behavior for optimal results.

Core Parameters

Temperature (0.0 - 2.0)

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]

Top P (0.0 - 1.0)

Alternative to temperature. Controls diversity by probability threshold.

How it works: Model generates candidate words with probabilities:

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.

Presence Penalty (-2.0 to 2.0)

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]

Frequency Penalty (-2.0 to 2.0)

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]

Reasoning Effort (Claude Sonnet 4 Only)

low

medium [Default]

high

DeFi Analysis Agent

{
  "frequency_penalty": 0.3,
  "presence_penalty": 0.2,
  "reasoning_effort": "medium",
  "temperature": 0.3,
  "top_p": 0.8
}

Consistent, factual, avoids repetition

Creative Content Writer

{
  "frequency_penalty": 0.6,
  "presence_penalty": 0.5,
  "reasoning_effort": "low",
  "temperature": 0.9,
  "top_p": 0.95
}

Diverse, creative, varied vocabulary

Code Generator

{
  "frequency_penalty": 0.0,
  "presence_penalty": 0.0,
  "reasoning_effort": "high",
  "temperature": 0.1,
  "top_p": 0.9
}

Deterministic, precise, allows technical repetition

Research Assistant

{
  "frequency_penalty": 0.2,
  "presence_penalty": 0.1,
  "reasoning_effort": "high",
  "temperature": 0.4,
  "top_p": 0.85
}

Thorough, analytical, comprehensive

Trading Advisor

{
  "frequency_penalty": 0.1,
  "presence_penalty": 0.0,
  "reasoning_effort": "medium",
  "temperature": 0.2,
  "top_p": 0.8
}

Consistent, reliable, factual

Tuning Tips

Start Conservative

Begin with default/low values, then increase gradually:

  1. Test with temperature = 0.3
  2. If too rigid, bump to 0.5
  3. Adjust incrementally until optimal

Single Variable

Change ONE parameter at a time to understand its effect.

Context Matters

Monitor Quality

Track across multiple queries:

Parameter Interactions

Temperature + Top P

Presence + Frequency Penalties

Reasoning Effort + Temperature

Advanced: Context Window

Max Tokens Not a tuning parameter, but important:

Models:

For agents, set based on expected output:

Troubleshooting

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

Testing Methodology

  1. Baseline: Test with defaults
  2. Hypothesis: “Increasing temp will make more creative”
  3. Test: Run same query 5x with temp=0.8
  4. Measure: Rate creativity, accuracy, consistency
  5. Compare: vs baseline
  6. Iterate: Adjust and retest

Resources


Experiment and iterate - optimal settings vary by use case and agent personality.