Agent with Tool Registration in Oracle AI Data Platform Workbench

Oracle AI Data Platform Workbench supports flexible agent construction and internal tool orchestration. This topic provides a sample recommended approach for defining, registering, and using tools within an agent.

1. Describe tools via configuration

Each tool is a Python dictionary:

my_tool = {
    "name": "blog_idea_tool",
    "description": "Generate blog ideas for a topic.",
    "class": "PromptTool",
    "conf": {...},  # tool-specific settings
    "params": [
        {"name": "topic", "type": "string", "description": "Blog topic"}
    ]
}

2. Register tools in a registry/config

All user tools are collected in a registry for agent lookup:

tool_conf = {
    "blog_idea_tool": my_tool,
    "social_post_tool": another_tool,
    # ... more tools
}

3. Framework wrapping: Create agent-consumable tool objects

Agent construction requires converting these dicts to executable tool objects (StructuredTool or similar):

from langchain_core.tools import StructuredTool

def create_langgraph_tool(tool):
    def tool_fn(**kwargs):
        # Example implementation: you would use utils.call_tool_by_name/tool runner, etc.
        return f"Executed {tool['name']} with inputs: {kwargs}"
    return StructuredTool.from_function(
        func=tool_fn,
        name=tool['name'],
        description=tool['description'],
        args_schema=None,  # Build a pydantic schema if detailed validation required
        infer_schema=False
    )

4. Memory and Using a Checkpointer

Agents in AI Data Platform Workbench often need memory to persist intermediate state, enable resumability, and allow for recovery after failures or across long-running workflows. The typical mechanism is a checkpointer object, which saves and restores agent state.

# Suppose you have a 'checkpointer' object available:
# It might be provided to your agent context directly, or created via aidp-agent-runtime utilities

# During agent run:
state = {"step": "tool_invoked", "result": tool_result}

if checkpointer:
    checkpointer.save(state)
    # To restore later:
    loaded_state = checkpointer.load()
    print(f"Restored state: {loaded_state}")

# You can persist any serializable agent context, params, or partial results
Usage pattern:
  • Pass the 'checkpointer' to agent code/class at construction or as a global/context variable.
  • Save state after every critical agent event, like tool output, prompt step, or LLM generation.
  • Restore state on agent restart, if available.
Typical sources of the checkpointer:
  • In AI Data Platform Workbench demo code, a `checkpointer` may be injected via workflow configuration or globals, e.g. `checkpointer = globals().get("checkpointer", None)`
  • For complex use-cases, the checkpointer may wrap external storage, databases, or cloud state to allow robust failure recovery.
# Inside agent code
checkpointer = globals().get("checkpointer", None)
if checkpointer:
    checkpointer.save({"step": "after_tool", "context": context_vars})
    # ...
    restored_state = checkpointer.load()