Local Testing
Before publishing, verify your workspace loads, admits cleanly, registers its tools, and round-trips through the mock sandbox. This page walks through the flow.
Prerequisites
You need the Bahulam backend running locally. From codekepler-backend/:
docker compose up -dVerify:
curl -s http://localhost:8150/health
# {"status":"healthy","version":"2.0.0","agent_framework":"3.4.20"}Ensure SANDBOX_EXECUTOR=mock in your dev env (or unset — mock is the
default). Real MicroVM dispatch is disabled locally.
Load Your Workspace via the Factory
The WorkspaceAgent.from_config factory is the single entry point:
import asyncio
from app.agent.workspace_agent import WorkspaceAgent, RunContext
async def smoke():
ctx = RunContext(
job_id="local-test",
gateway=None, # only needed if you'll run.run()
tool_executor=None,
session_id="local-session",
channel="api",
user_id="local-user",
)
agent = await WorkspaceAgent.from_config(
"community/your-handle/your-workspace",
ctx,
)
print("Loaded. Tools:", len(agent.all_tools))
asyncio.run(smoke())If load succeeds, you’ll see:
[WorkspaceAgent] Loaded community workspace: community/your-handle/your-workspace
[WorkspaceAgent] Loaded N custom_tools file(s) for community/your-handle/your-workspace from tools/
Loaded. Tools: 3If it fails, admission errors surface as a ValueError with structured
codes.
Reading Admission Errors
Every failure has a code you can act on:
| Code | What it means | Fix |
|---|---|---|
metadata_name_missing | Community workspace didn’t set metadata.name | Add the field to workspace.yaml. |
metadata_author_missing | Same for author. | Add. Must match community/<author>/ path. |
metadata_version_missing | Same for version. | Add a SemVer. |
tool_not_registered | tools: list references a name not in the registry | Add to imports: OR to custom_tools: OR fix a typo. |
reserved_namespace_shadowing | Custom tool uses bahulam.<verified>.* prefix | Rename to bahulam.community.<handle>.<verb>. |
custom_tools_path_missing | custom_tools.path doesn’t exist on disk | Create the dir or fix the path. |
limits_memory_exceeded | memory_mb above 2048 | Lower it. |
limits_cpu_exceeded | cpu above 2.0 | Lower it. |
limits_wall_seconds_exceeded | wall_seconds above 300 | Lower it. |
Warnings are logged but not fatal:
| Code | What it means |
|---|---|
network_undeclared | Your Python imports httpx/requests/urllib but network.egress is empty. |
tool_not_registered (verified only) | A tool name in tools: doesn’t resolve, but Bahulam trusts verified workspaces to register through framework paths. |
Trigger a Tool Call Directly
Once the workspace loads, you can dispatch a tool through the registry:
from app.agent.tools.registry import execute_tool
# Direct call, no LLM in the loop
result = await execute_tool(
"bahulam.community.your-handle.hello_greet",
{"person": "Alice"},
task_id="local-test",
)
print(result)With SANDBOX_EXECUTOR=mock you get a marker:
{
"sandbox_executor": "mock",
"workspace_id": "community/your-handle/your-workspace",
"custom_tool_path": "tools/hello_tool.py",
"tool_name": "bahulam.community.your-handle.hello_greet",
"args": {"person": "Alice"},
"message": "MockSandboxExecutor did not execute the tool...",
}Your _inside_sandbox body did NOT run. That’s expected — the mock only
confirms the pipeline works end-to-end.
Testing the _inside_sandbox Body Directly
For unit tests of the tool body itself, call the method directly:
def test_hello_greet_body():
from tools.hello_tool import HelloGreetTool
result = HelloGreetTool()._inside_sandbox(person="Alice")
assert result == {"greeting": "Hello, Alice!"}This bypasses the sandbox and runs the code in-process. Fine for pure
logic tests, but any code path that depends on connections (via
ctx.connections) won’t work here — mock the ctx or split the pure logic
into its own testable function.
Full LLM Round-Trip
To actually run your workspace with an LLM in the loop (matching what users will experience), you need to wire a gateway. From the codebase:
from agent_framework.composable.gateways import GatewayFactory, CacheConfig
from agent_framework.composable.gateways.config_builder import build_gateway_config
gw_config = build_gateway_config(
provider="openrouterv2",
secrets={"openrouter_api_key": "sk-or-v1-..."},
model="deepseek/deepseek-v4-flash",
max_tokens=2048,
temperature=0.5,
cache=CacheConfig(
enabled=True,
cache_system_prompt=True,
cache_tools=True,
cache_messages=True,
),
)
gateway = GatewayFactory.create("openrouterv2", config=gw_config)Pass into RunContext(gateway=gateway, ...). Then:
async for event in agent.run("Say hello to Alice."):
print(event.type, event.data)You’ll see the LLM pick your tool, the mock executor return a marker, and the LLM summarize the marker in its reply. Not useful in isolation, but confirms the full agent loop reaches your tool.
Checklist Before Publishing
Before opening a PR to the community hub:
-
workspace.yamlhasmetadata.name,author,version. - All tools use
bahulam.community.<handle>.<verb>naming. -
custom_tools.limitswithin ceilings (cpu ≤ 2, memory ≤ 2048, wall ≤ 300). -
custom_tools.network.egressdeclares every host your code talks to. -
connections_requiredlists every OAuth-brokered dependency. - Local factory load succeeds without fatal admission errors.
- Direct
execute_tool()call returns the mock marker (proves registration). - Unit tests on
_inside_sandboxbodies pass. - README explains what the workspace does and any user setup steps.
See Publishing for the submission flow.