When using OpenAI models ( etc.) with the Agentica SDK, apply these proven strategies:Writing Agentic Function DocstringsCrafting Agent PremisesRequest Step-by-Step ReasoningFor complex tasks, explicitly ask for reasoning in your docstrings or premises:Leverage Scope EffectivelyProvide focused, relevant tools rather than entire SDKs:Type Hints are InstructionsOpenAI models excel at following type hints — use them to guide output:
When using Anthropic models ( etc.) with the Agentica SDK, leverage these Claude-specific strengths:XML Tags in DocstringsClaude excels at parsing XML structure — use it in complex agentic functions:Rich Agent PremisesClaude responds well to detailed role definitions:Chain of Thought PromptsClaude’s reasoning improves dramatically with explicit thinking requests:Long Context UtilizationClaude handles large contexts exceptionally well — structure them clearly:
Prompting Style DifferencesOpenAI Models ( etc.):2. Use Strong Type Hints. Types guide agents and ensure type-safe returns.3. Provide Focused Scope. Only include tools/data agents need for the specific task, not entire objects or SDKs.4. Request Reasoning for Complex Tasks. Add “step by step” or “think through” to prompts for better accuracy on hard problems.5. Test with Real Examples. Validate agentic functions and agents with actual use cases before production.
- Concise instructions. Works well with shorter, direct docstrings and premises.
- Delimiters. Use
###or"""to separate sections in complex prompts. - Step-by-step explicit. Benefits from phrases like “First… Then… Finally…”
- Function-oriented. Natural fit for task decomposition and tool use.
- XML tags preferred. Use
<instructions>,<context>,<examples>for structure. - Detailed premises. Responds well to longer, more elaborate role definitions.
- Chain of thought. Explicitly request thinking with “Before answering, think step by step…”
- Long context friendly. Can handle very large prompts and scope effectively.
Choosing Models with the Agentica SDK
Consider OpenAI when:- Your prompts are concise and task-focused
- You’re using structured delimiters for prompt sections
- Example:
model="openai/gpt-5"
- Your prompts benefit from XML structure
- You’re working with very large context in scope
- You want detailed, persona-driven agents
- Example:
model="anthropic/claude-opus-4.6"
Be Specific
Vague prompts lead to inconsistent results. Agents need clear instructions about what you want, how you want it, and what format to return. Think of your docstring as a specification, not just a description. Bad approach: Generic verbs without details.Include Examples
When you need specific formatting or a particular style, showing examples is more effective than describing the desired output in words. Models learn patterns quickly from concrete examples. Use examples for tasks where the output has specific structure, like generating changelog entries:Define Constraints
Agents need explicit rules for handling edge cases and ambiguous inputs. Without clear constraints, you’ll get inconsistent behavior when inputs don’t match the happy path. When your task involves categorization or decision-making, spell out the criteria:Agents
For agents, the Agentica SDK formats an initial system role message using the providedpremise on instantiation.
Any subsequent invocation or call of an agent formats a user role message using the provided task.
The premise should provide additional context on the agent’s overall purpose or goal over its lifetime, while the task should provide information about its immediate goal, linked to the specified return type.
Custom prompts
Both the Python and TypeScript SDK offer the ability to provide an entirely custom system role message for agents via thesystem argument in spawn.
If system is provided instead of premise, then system will be the exact system role message on instantiation and task will be the exact user role message on invocation of the agent, without any formatting.
Templating variables
To include information about the environment and the agent’s capabilities in your customsystem prompts and task, a number of templatable “explainer” variables are exported in the Agentica SDK.
These are formatted using the template function and these variables slightly differ per model.
Agentic functions
Templating variables
To include information about the environment and the agent’s capabilities when writing an agentic function, a number of templatable “explainer” variables are exported in the Agentica SDK. These are formatted using thetemplate function and these variables slightly differ per model.