Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.upsonic.ai/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Register callback functions to be notified when agents interact with skills. Useful for logging, analytics, and custom monitoring.

Available Callbacks

CallbackTriggered WhenArguments
on_loadAgent loads a skill’s instructionsskill_name: str, description: str
on_script_executeAgent executes a skill scriptskill_name: str, script_path: str, returncode: int
on_reference_accessAgent reads a skill referenceskill_name: str, reference_path: str

Usage

from upsonic import Agent
from upsonic.skills import Skills, LocalSkills


def on_skill_loaded(skill_name: str, description: str):
    print(f"[SKILL LOADED] {skill_name}: {description}")


def on_script_executed(skill_name: str, script_path: str, returncode: int):
    print(f"[SCRIPT RUN] {skill_name}/{script_path} -> exit code {returncode}")


def on_reference_accessed(skill_name: str, reference_path: str):
    print(f"[REFERENCE READ] {skill_name}/{reference_path}")


skills = Skills(
    loaders=[LocalSkills("./my-skills")],
    on_load=on_skill_loaded,
    on_script_execute=on_script_executed,
    on_reference_access=on_reference_accessed,
)

agent = Agent(
    model="anthropic/claude-sonnet-4-6",
    name="Agent",
    role="Developer Assistant",
    goal="Assist with development tasks",
    skills=skills,
)

result = agent.print_do("Review this code using the code-review skill.")
# Output:
# [SKILL LOADED] code-review: Code quality analysis and best practices
# [REFERENCE READ] code-review/style-guide.md

Error Handling

Callback exceptions are caught and logged as warnings — they never interrupt the agent’s execution:
def buggy_callback(skill_name: str, description: str):
    raise ValueError("oops")

skills = Skills(
    loaders=[LocalSkills("./my-skills")],
    on_load=buggy_callback,  # Logs warning, doesn't crash
)