Skip to main content
When using OpenAI models ( etc.) with the Agentica SDK, apply these proven strategies:Writing Agentic Function Docstrings
Crafting Agent Premises
Request 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.):
  • 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.
Anthropic Models ( etc.):
  • 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.
Universal Agentica SDK Best PracticesRegardless of model choice:1. Write Clear Docstrings/Descriptions. Be specific about what, how, and what format to return.
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.

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"
Consider Anthropic when:
  • 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"
Prompting Approach:

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.
Good approach: Specify length, focus, and style.
When behavior or style matters beyond just the output structure, specify it clearly. Types tell agents what to return, but your prompt tells it how to get there.

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:
Multiple examples help establish patterns, especially for formatting that varies by input:

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:
For parsing or extraction tasks, define what constitutes valid input and what to return when inputs are missing or malformed:
For multi-step validation workflows, use an agent that progressively checks and adapts based on what it discovers. The agent remembers previous findings when deciding next steps:

Agents

For agents, the Agentica SDK formats an initial system role message using the provided premise 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 the system 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 custom system 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.
For more information on template see here for Python and here for TypeScript.For precise values of these variables see here.
Note that template is not supported for an agent premise for both the Python and TypeScript SDKs.

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 the template function and these variables slightly differ per model.
For more information on template see here for Python and here for TypeScript.For precise values of these variables see here.
Note that template is not supported for doc-strings of agentic functions for the Python SDK.