-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
complexity:averageModerate effort, some design neededModerate effort, some design neededphase:executionRouter, driversRouter, driverspriority:highCore functionalityCore functionalitysize:MMedium change, 50 to 200 linesMedium change, 50 to 200 linestype:featureNew functionalityNew functionality
Milestone
Description
Parent: #40 | Split: OpenAI adapter
Problem
This is part 1 of #40. Developers using OpenAI's API must manually translate between Capability objects and OpenAI's {type: "function", name, description, parameters} tool schema. This is tedious and blocks adoption.
Proposed Change
1. Schema adapter (src/agent_kernel/adapters/openai.py)
def capabilities_to_tools(caps: list[Capability]) -> list[dict]:
"""Convert Capabilities to OpenAI function tool definitions."""
def tool_call_to_request(tool_call: dict) -> CapabilityRequest:
"""Convert an OpenAI tool_call to a CapabilityRequest."""
def format_result(result: Any) -> dict:
"""Format kernel invoke() result as OpenAI function_call_output."""2. Middleware class
class OpenAIMiddleware:
def __init__(self, kernel: Kernel, principal: Principal): ...
def get_tools(self) -> list[dict]: ...
async def handle_tool_calls(self, response_output: list[dict]) -> list[dict]: ...
def intercept_tool_call(self, callback: Callable) -> None: ...
def intercept_tool_result(self, callback: Callable) -> None: ...3. Namespace mapping
Map dot-notation capability IDs to OpenAI namespace format:
billing.list_invoices→ namespacebilling, functionlist_invoices
4. No SDK dependency
Adapters work with plain dicts — no dependency on openai package.
Acceptance Criteria
- Round-trip:
Capability→ OpenAI schema →tool_call→CapabilityRequestpreserves all fields -
OpenAIMiddleware.handle_tool_calls()processes through full kernel pipeline -
intercept_tool_call()andintercept_tool_result()hooks execute correctly - Namespace mapping for dot-notation capability IDs
- Schema matches current OpenAI API spec (Responses + Chat Completions)
- No runtime dependency on
openaipackage
Affected Files
src/agent_kernel/adapters/__init__.py(new)src/agent_kernel/adapters/openai.py(new)tests/test_adapters.py(new)docs/integrations.md(usage examples)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
complexity:averageModerate effort, some design neededModerate effort, some design neededphase:executionRouter, driversRouter, driverspriority:highCore functionalityCore functionalitysize:MMedium change, 50 to 200 linesMedium change, 50 to 200 linestype:featureNew functionalityNew functionality