Backend Abstraction Layer¶
The backend abstraction layer provides a provider-agnostic interface for agent
execution. Downstream consumers (test runner, chat session, serve endpoint)
depend only on the protocols defined in holodeck.lib.backends.base -- no
provider-specific types leak through.
Routing¶
BackendSelector inspects model.provider and instantiates the correct
backend automatically:
| Provider | Backend |
|---|---|
openai, azure_openai, ollama |
SKBackend |
anthropic |
ClaudeBackend |
holodeck.lib.backends.base -- Core Protocols & Data Classes¶
Defines the provider-agnostic contracts that every backend must satisfy and the unified result types returned to callers.
ExecutionResult¶
ExecutionResult(response, tool_calls=list(), tool_results=list(), token_usage=TokenUsage.zero(), structured_output=None, num_turns=1, is_error=False, error_reason=None)
dataclass
¶
Provider-agnostic result of a single agent turn.
Attributes:
| Name | Type | Description |
|---|---|---|
response |
str
|
The text response from the agent. |
tool_calls |
list[dict[str, Any]]
|
List of tool call records made during execution. |
tool_results |
list[dict[str, Any]]
|
List of tool result records returned during execution. |
token_usage |
TokenUsage
|
Token consumption metadata for this turn. |
structured_output |
Any | None
|
Optional structured output from the agent. |
num_turns |
int
|
Number of turns taken to produce this result. |
is_error |
bool
|
Whether the execution ended in an error state. |
error_reason |
str | None
|
Human-readable reason for the error, if any. |
ToolEvent¶
ToolEvent(kind, tool_name, tool_use_id, tool_input=None, tool_response=None, error=None)
dataclass
¶
Real-time tool execution event from the backend.
Emitted by backends that support hook-based tool observation (e.g. Claude
Agent SDK). Events are pushed onto an asyncio.Queue that consumers
can drain concurrently during agent execution.
Attributes:
| Name | Type | Description |
|---|---|---|
kind |
Literal['start', 'end', 'error']
|
Event type — |
tool_name |
str
|
Name of the tool being invoked. |
tool_use_id |
str
|
Unique identifier correlating start/end/error for the same invocation. |
tool_input |
dict[str, Any] | None
|
Tool input parameters (present on |
tool_response |
str | None
|
Tool output (present on |
error |
str | None
|
Error description (present on |
AgentSession¶
AgentSession
¶
Bases: Protocol
Stateful multi-turn conversation session.
Implementations maintain conversation history across multiple send
calls. Callers must invoke close when the session is no longer needed
to release any held resources (connections, subprocesses, etc.).
close()
async
¶
Release session resources (connections, subprocesses, etc.).
Source code in src/holodeck/lib/backends/base.py
106 107 108 | |
send(message)
async
¶
Send a message and receive a single-turn result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
The user message to send to the agent. |
required |
Returns:
| Type | Description |
|---|---|
ExecutionResult
|
ExecutionResult containing the agent response and metadata. |
Source code in src/holodeck/lib/backends/base.py
83 84 85 86 87 88 89 90 91 92 | |
send_streaming(message)
async
¶
Send a message and stream the agent response token by token.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
The user message to send to the agent. |
required |
Yields:
| Type | Description |
|---|---|
AsyncGenerator[str, None]
|
Successive string chunks of the agent response. |
Source code in src/holodeck/lib/backends/base.py
94 95 96 97 98 99 100 101 102 103 104 | |
AgentBackend¶
AgentBackend
¶
Bases: Protocol
Provider backend factory.
Each backend encapsulates provider-specific initialisation logic and
exposes a uniform surface for single-turn invocations (invoke_once)
and stateful sessions (create_session). Callers must call
initialize before any other method and teardown when done.
create_session()
async
¶
Create a new stateful multi-turn session.
Returns:
| Type | Description |
|---|---|
AgentSession
|
A fresh AgentSession instance bound to this backend. |
Raises:
| Type | Description |
|---|---|
BackendInitError
|
If the backend was not initialised before calling. |
BackendSessionError
|
If the session cannot be created. |
Source code in src/holodeck/lib/backends/base.py
150 151 152 153 154 155 156 157 158 159 160 | |
initialize()
async
¶
Prepare the backend for use.
Raises:
| Type | Description |
|---|---|
BackendInitError
|
If the backend cannot be initialised (e.g. missing API key, unavailable subprocess). |
Source code in src/holodeck/lib/backends/base.py
121 122 123 124 125 126 127 128 | |
invoke_once(message, context=None)
async
¶
Execute a single stateless agent turn.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
The user message to send to the agent. |
required |
context
|
list[dict[str, Any]] | None
|
Optional list of prior conversation turns. |
None
|
Returns:
| Type | Description |
|---|---|
ExecutionResult
|
ExecutionResult containing the agent response and metadata. |
Raises:
| Type | Description |
|---|---|
BackendSessionError
|
If the invocation fails at runtime. |
BackendTimeoutError
|
If the invocation exceeds configured timeout. |
Source code in src/holodeck/lib/backends/base.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
teardown()
async
¶
Release all backend resources.
Source code in src/holodeck/lib/backends/base.py
162 163 164 | |
ContextGenerator¶
ContextGenerator
¶
Bases: Protocol
Backend-agnostic contextual embedding generation.
Implementations produce situating context for document chunks by summarising each chunk's role within the larger document. Both the existing Semantic Kernel generator and future Claude SDK generator should satisfy this protocol.
contextualize_batch(chunks, document_text, concurrency=None)
async
¶
Generate contextual descriptions for a batch of chunks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunks
|
list[DocumentChunk]
|
Document chunks to contextualize. |
required |
document_text
|
str
|
Full text of the source document. |
required |
concurrency
|
int | None
|
Maximum number of concurrent LLM calls. |
None
|
Returns:
| Type | Description |
|---|---|
list[str]
|
A list of contextual description strings, one per chunk. |
Source code in src/holodeck/lib/backends/base.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
Exceptions¶
BackendError
¶
Bases: HoloDeckError
Base exception for all backend errors.
Catch this to handle any backend-related failure without needing to know the specific subtype.
BackendInitError
¶
Bases: BackendError
Raised during initialize() — startup validation failures.
Examples include a missing API key, an unreachable subprocess, or an incompatible runtime environment.
BackendSessionError
¶
Bases: BackendError
Raised during send() — session-level failures.
Examples include unexpected disconnections, malformed responses, or provider-reported errors during an active session.
BackendTimeoutError
¶
Bases: BackendError
Raised when a single invocation exceeds the configured timeout.
Callers may choose to retry with a longer timeout or surface this as a user-visible error.
holodeck.lib.backends.selector -- Backend Routing¶
Routes an Agent configuration to the correct backend based on
model.provider.
BackendSelector¶
BackendSelector
¶
Selects and initializes the appropriate backend for an agent configuration.
select(agent, tool_instances=None, mode='test', allow_side_effects=False)
async
staticmethod
¶
Select and initialize the appropriate backend for the given agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
Agent
|
Agent configuration with model provider information. |
required |
tool_instances
|
dict[str, Any] | None
|
Initialized tool instances for Claude backend. |
None
|
mode
|
str
|
Execution mode ( |
'test'
|
allow_side_effects
|
bool
|
Allow bash/file_system.write in test mode. |
False
|
Returns:
| Type | Description |
|---|---|
AgentBackend
|
An initialized AgentBackend instance ready for use. |
Raises:
| Type | Description |
|---|---|
BackendInitError
|
If the provider is not supported or initialization fails. |
Source code in src/holodeck/lib/backends/selector.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
holodeck.lib.backends.sk_backend -- Semantic Kernel Backend¶
Wraps the existing AgentFactory / AgentThreadRun infrastructure behind the
provider-agnostic backend interfaces. Handles OpenAI, Azure OpenAI, and Ollama
providers.
SKBackend¶
SKBackend(agent_config)
¶
Semantic Kernel backend implementing the AgentBackend protocol.
Wraps AgentFactory to provide the provider-agnostic backend interface used by downstream consumers.
Initialize the SK backend with agent configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_config
|
Agent
|
Agent configuration with model and instructions. |
required |
Source code in src/holodeck/lib/backends/sk_backend.py
103 104 105 106 107 108 109 | |
create_session()
async
¶
Create a new stateful multi-turn session.
Returns:
| Type | Description |
|---|---|
AgentSession
|
An SKSession instance bound to a fresh thread run. |
Source code in src/holodeck/lib/backends/sk_backend.py
140 141 142 143 144 145 146 147 | |
initialize()
async
¶
Prepare the backend for use by initializing tools.
Source code in src/holodeck/lib/backends/sk_backend.py
111 112 113 | |
invoke_once(message, context=None)
async
¶
Execute a single stateless agent turn.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
The user message to send to the agent. |
required |
context
|
list[dict[str, Any]] | None
|
Optional list of prior conversation turns (unused for now). |
None
|
Returns:
| Type | Description |
|---|---|
ExecutionResult
|
ExecutionResult containing the agent response and metadata. |
Source code in src/holodeck/lib/backends/sk_backend.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
teardown()
async
¶
Release all backend resources.
Source code in src/holodeck/lib/backends/sk_backend.py
149 150 151 | |
SKSession¶
SKSession(thread_run)
¶
Stateful multi-turn session backed by an AgentThreadRun.
Implements the AgentSession protocol by delegating to the underlying Semantic Kernel thread run for conversation management.
Initialize session with an AgentThreadRun.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
thread_run
|
Any
|
An AgentThreadRun instance from AgentFactory. |
required |
Source code in src/holodeck/lib/backends/sk_backend.py
49 50 51 52 53 54 55 | |
close()
async
¶
Release session resources. No-op for SK sessions.
Source code in src/holodeck/lib/backends/sk_backend.py
91 92 93 | |
send(message)
async
¶
Send a message and receive a single-turn result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
The user message to send to the agent. |
required |
Returns:
| Type | Description |
|---|---|
ExecutionResult
|
ExecutionResult containing the agent response and metadata. |
Source code in src/holodeck/lib/backends/sk_backend.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
send_streaming(message)
async
¶
Send a message and stream the response.
Currently delegates to send() and yields the full response as a single chunk. True streaming will be implemented in a future phase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
The user message to send to the agent. |
required |
Yields:
| Type | Description |
|---|---|
AsyncGenerator[str, None]
|
String chunks of the agent response. |
Source code in src/holodeck/lib/backends/sk_backend.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
holodeck.lib.backends.claude_backend -- Claude Agent SDK Backend¶
Implements the backend for provider: anthropic. Single-turn invocations use
the top-level query() SDK function; multi-turn chat sessions use
ClaudeSDKClient.
ClaudeBackend¶
ClaudeBackend(agent, tool_instances=None, mode='test', allow_side_effects=False)
¶
Backend implementation for the Claude Agent SDK.
Implements the AgentBackend protocol. Single-turn invocations use the
top-level query() function. Multi-turn sessions use ClaudeSession
wrapping ClaudeSDKClient.
The constructor stores config only — no I/O, no subprocess spawned.
Initialization is deferred to initialize() (called lazily on first use).
Store configuration without performing any I/O.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
Agent
|
Agent configuration. |
required |
tool_instances
|
dict[str, Any] | None
|
Initialized vectorstore/hierarchical-doc tool instances. |
None
|
mode
|
str
|
Execution mode ( |
'test'
|
allow_side_effects
|
bool
|
Allow bash/file_system.write in test mode. |
False
|
Source code in src/holodeck/lib/backends/claude_backend.py
679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 | |
create_session()
async
¶
Create a new multi-turn session.
Automatically initializes if not yet done.
Returns:
| Type | Description |
|---|---|
ClaudeSession
|
A new |
Source code in src/holodeck/lib/backends/claude_backend.py
948 949 950 951 952 953 954 955 956 957 958 959 | |
initialize()
async
¶
Initialize the backend — validate config, build options.
Idempotent: calling multiple times is a no-op after the first.
Raises:
| Type | Description |
|---|---|
BackendInitError
|
On validation or configuration failure. |
Source code in src/holodeck/lib/backends/claude_backend.py
708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 | |
invoke_once(message, context=None)
async
¶
Invoke the agent for a single turn.
Automatically initializes if not yet done. Retries on ProcessError
(subprocess crash) with exponential backoff.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
User message text. |
required |
context
|
list[dict[str, Any]] | None
|
Optional conversation context (unused for Claude backend). |
None
|
Returns:
| Type | Description |
|---|---|
ExecutionResult
|
|
Raises:
| Type | Description |
|---|---|
BackendSessionError
|
After max retries exhausted. |
Source code in src/holodeck/lib/backends/claude_backend.py
785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 | |
teardown()
async
¶
Reset backend state, releasing any built options.
Source code in src/holodeck/lib/backends/claude_backend.py
1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 | |
ClaudeSession¶
ClaudeSession(options)
¶
Stateful multi-turn session backed by ClaudeSDKClient.
Each session maintains a session_id across turns. Multi-turn state is
opt-in: after the first turn, subsequent turns pass
continue_conversation=True and resume=session_id to the SDK.
The _base_options reference is never mutated. Turn-specific options
are created as new ClaudeAgentOptions instances.
Initialize session with base options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
ClaudeAgentOptions
|
Base options (immutable reference for the session lifetime). |
required |
Source code in src/holodeck/lib/backends/claude_backend.py
488 489 490 491 492 493 494 495 496 497 498 | |
tool_events
property
¶
Queue of real-time tool events emitted via SDK hooks.
close()
async
¶
Disconnect the SDK client and release resources.
Source code in src/holodeck/lib/backends/claude_backend.py
658 659 660 | |
release_transport()
async
¶
Disconnect the SDK client without losing session state.
After calling this, the next send() or send_streaming() call
will create a fresh ClaudeSDKClient and reconnect, resuming the
conversation via the preserved session_id.
This is required when the session is used across different async task
contexts (e.g., HTTP requests in holodeck serve), because the
SDK's anyio task group is bound to the task that called connect().
Source code in src/holodeck/lib/backends/claude_backend.py
643 644 645 646 647 648 649 650 651 652 653 654 655 656 | |
send(message)
async
¶
Send a message and collect the full response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
User message text. |
required |
Returns:
| Type | Description |
|---|---|
ExecutionResult
|
|
Raises:
| Type | Description |
|---|---|
BackendSessionError
|
On subprocess or SDK error. |
Source code in src/holodeck/lib/backends/claude_backend.py
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 | |
send_streaming(message)
async
¶
Send a message and yield text chunks progressively.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
User message text. |
required |
Yields:
| Type | Description |
|---|---|
AsyncGenerator[str, None]
|
Text chunks as they arrive from the SDK. |
Raises:
| Type | Description |
|---|---|
BackendSessionError
|
On subprocess or SDK error. |
Source code in src/holodeck/lib/backends/claude_backend.py
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 | |
build_options¶
build_options(*, agent, tool_server, tool_names, mcp_configs, auth_env, otel_env, mode, allow_side_effects)
¶
Assemble ClaudeAgentOptions from agent config and bridge outputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
Agent
|
The agent configuration. |
required |
tool_server
|
McpSdkServerConfig | None
|
In-process MCP server for vectorstore/hierarchical-doc tools. |
required |
tool_names
|
list[str]
|
Allowed tool names from the in-process server. |
required |
mcp_configs
|
dict[str, Any]
|
External MCP server configs from |
required |
auth_env
|
dict[str, str]
|
Auth env vars from |
required |
otel_env
|
dict[str, str]
|
OTel env vars from |
required |
mode
|
str
|
Execution mode ( |
required |
allow_side_effects
|
bool
|
Whether side effects are allowed in test mode. |
required |
Returns:
| Type | Description |
|---|---|
ClaudeAgentOptions
|
Configured |
Source code in src/holodeck/lib/backends/claude_backend.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
holodeck.lib.backends.tool_adapters -- Claude SDK Tool Adapters¶
Wraps HoloDeck vectorstore and hierarchical-document tools as @tool-decorated
functions, bundles them into an in-process MCP server, and provides a factory
for ClaudeBackend to call during initialization.
VectorStoreToolAdapter¶
VectorStoreToolAdapter(config, instance)
¶
Wraps a VectorStoreTool for use with the Claude Agent SDK.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
VectorstoreTool
|
The vectorstore tool configuration from the agent YAML. |
required |
instance
|
VectorStoreTool
|
An initialized |
required |
Source code in src/holodeck/lib/backends/tool_adapters.py
98 99 100 101 102 103 104 | |
to_sdk_tool()
¶
Return an SdkMcpTool backed by this adapter's search method.
Source code in src/holodeck/lib/backends/tool_adapters.py
106 107 108 109 110 111 112 | |
HierarchicalDocToolAdapter¶
HierarchicalDocToolAdapter(config, instance)
¶
Wraps a HierarchicalDocumentTool for use with the Claude Agent SDK.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
HierarchicalDocumentToolConfig
|
The hierarchical document tool configuration from the agent YAML. |
required |
instance
|
HierarchicalDocumentTool
|
An initialized |
required |
Source code in src/holodeck/lib/backends/tool_adapters.py
123 124 125 126 127 128 129 | |
to_sdk_tool()
¶
Return an SdkMcpTool backed by this adapter's search method.
Source code in src/holodeck/lib/backends/tool_adapters.py
131 132 133 134 135 136 137 | |
create_tool_adapters¶
create_tool_adapters(tool_configs, tool_instances)
¶
Build adapters for vectorstore and hierarchical-document tools.
Filters tool_configs for supported types, matches each to its
initialized instance by config.name, and returns adapter objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_configs
|
list[ToolUnion]
|
All tool configurations from the agent YAML. |
required |
tool_instances
|
dict[str, VectorStoreTool | HierarchicalDocumentTool]
|
Initialized tool instances keyed by config name. |
required |
Returns:
| Type | Description |
|---|---|
list[VectorStoreToolAdapter | HierarchicalDocToolAdapter]
|
List of adapter objects ready for |
Raises:
| Type | Description |
|---|---|
BackendInitError
|
If a supported tool config has no matching instance. |
Source code in src/holodeck/lib/backends/tool_adapters.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
build_holodeck_sdk_server¶
build_holodeck_sdk_server(adapters)
¶
Bundle adapters into an in-process MCP server for the Claude subprocess.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapters
|
list[VectorStoreToolAdapter | HierarchicalDocToolAdapter]
|
Adapter objects produced by |
required |
Returns:
| Type | Description |
|---|---|
McpSdkServerConfig
|
A tuple of |
list[str]
|
server_config is a |
tuple[McpSdkServerConfig, list[str]]
|
allowed_tool_names are the fully-qualified MCP tool names. |
Source code in src/holodeck/lib/backends/tool_adapters.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
holodeck.lib.backends.mcp_bridge -- MCP Configuration Bridge¶
Translates HoloDeck MCPTool configurations into Claude Agent SDK
McpStdioServerConfig format for subprocess-based MCP servers. Only stdio
transport tools are supported.
build_claude_mcp_configs¶
build_claude_mcp_configs(mcp_tools)
¶
Translate HoloDeck MCPTool configs to Claude SDK MCP server configs.
Only stdio transport tools are supported by the Claude subprocess. Non-stdio tools are skipped with a warning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mcp_tools
|
list[MCPTool]
|
List of MCPTool configurations from agent YAML. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, McpStdioServerConfig]
|
Dictionary mapping tool names to McpStdioServerConfig TypedDicts. |
Source code in src/holodeck/lib/backends/mcp_bridge.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
holodeck.lib.backends.otel_bridge -- Observability Bridge¶
Translates HoloDeck ObservabilityConfig into environment variable dicts that
configure OpenTelemetry for the Claude subprocess.
translate_observability¶
translate_observability(config)
¶
Translate ObservabilityConfig to env vars for the Claude subprocess.
Produces a dict of environment variable key-value pairs that configure OpenTelemetry in the Claude subprocess. All values are strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ObservabilityConfig
|
HoloDeck observability configuration from agent YAML. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Dictionary of environment variable names to string values. |
dict[str, str]
|
Empty dict if observability is disabled. |
Source code in src/holodeck/lib/backends/otel_bridge.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
holodeck.lib.backends.validators -- Startup Validators¶
Pre-flight checks called by ClaudeBackend.initialize() before spawning the
Claude subprocess. These surface configuration errors at startup rather than at
runtime.
validate_nodejs¶
validate_nodejs()
¶
Validate that Node.js is available on PATH.
Claude Agent SDK requires Node.js to spawn its subprocess.
Raises:
| Type | Description |
|---|---|
ConfigError
|
If node is not found on PATH. |
Source code in src/holodeck/lib/backends/validators.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
validate_credentials¶
validate_credentials(model)
¶
Validate authentication credentials for the LLM provider.
Checks that the required environment variables are present for the configured auth_provider, including cloud routing context for Bedrock, Vertex, and Foundry. Returns a dict of environment variables to inject into the Claude subprocess.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
LLMProvider
|
LLM provider configuration. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Dict of environment variables to set for the subprocess. |
Raises:
| Type | Description |
|---|---|
ConfigError
|
If required credentials are absent. |
Source code in src/holodeck/lib/backends/validators.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
validate_embedding_provider¶
validate_embedding_provider(agent)
¶
Validate embedding provider configuration for vectorstore tools.
Anthropic does not support generating embeddings, so an external embedding_provider must be specified when using vectorstore tools with the Anthropic LLM provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
Agent
|
Agent configuration to validate. |
required |
Raises:
| Type | Description |
|---|---|
ConfigError
|
If embedding configuration is invalid for the provider. |
Source code in src/holodeck/lib/backends/validators.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
validate_tool_filtering¶
validate_tool_filtering(agent)
¶
Warn if tool_filtering is configured for Anthropic provider.
Claude Agent SDK manages tool selection natively; tool_filtering is a Semantic Kernel feature that is not supported by the Claude backend.
This validator never raises — it only emits a warning. The tool_filtering field is not mutated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
Agent
|
Agent configuration to validate. |
required |
Source code in src/holodeck/lib/backends/validators.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
validate_working_directory¶
validate_working_directory(path)
¶
Warn if CLAUDE.md in working directory may conflict with agent instructions.
Detects a CLAUDE.md file that contains a '# CLAUDE.md' header, which is the standard format used by Claude Code project instructions. Such a file may override or conflict with the agent's configured instructions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | None
|
Working directory path, or None to skip validation. |
required |
Source code in src/holodeck/lib/backends/validators.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
validate_response_format¶
validate_response_format(response_format)
¶
Validate response format schema is serializable and accessible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response_format
|
dict[str, Any] | str | None
|
Inline schema dict, file path string, or None. |
required |
Raises:
| Type | Description |
|---|---|
ConfigError
|
If the schema is not JSON-serializable or file not found. |
Source code in src/holodeck/lib/backends/validators.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |