Architectural Lineage (Credits):
SwarmCraft is an architectural fork and deep rewrite of the multi-agent swarm engine created by Mojomast in mojomast/swarmussy.
SwarmCraft’s deterministic “Architect-style” layering is also derived from the meta-structure of Abstract Wiki Architect (AWA).
Full details: Credits & Lineage
SwarmCraft is powered by Grok through a dedicated provider adapter layer.
Goal:
This page documents the expected behavior of the Grok adapter, without tying the rest of the codebase to Grok-specific response shapes.
The Grok adapter MUST:
text outputThe adapter SHOULD:
SwarmCraft should call providers through a stable interface like:
class LLMProvider:
def generate(self, messages, tools=None, tool_choice=None, **opts) -> ProviderResult:
...
Where ProviderResult is normalized:
{
"text": "string",
"tool_calls": [
{
"name": "write_file",
"arguments": { "path": "...", "content": "..." }
}
],
"usage": {
"input_tokens": 0,
"output_tokens": 0,
"total_tokens": 0
},
"meta": {
"model": "grok-...",
"latency_ms": 0
}
}
This allows the orchestrator to remain unchanged if you later add other providers.
Recommended keys (names may vary by implementation):
GROK_API_KEYGROK_MODEL (default model id)GROK_BASE_URL (optional, if not default)Optional per-project settings file, e.g.:
projects/<project_id>/data/settings.jsonRecommended fields:
{
"llm": {
"provider": "grok",
"model": "grok-...",
"temperature": 0.7,
"max_tokens": 2000
}
}
SwarmCraft personas must not write files directly. They request tool calls.
The Grok adapter MUST support:
Tool execution remains in SwarmCraft (not in Grok):
This preserves deterministic safety rules:
Adapter SHOULD retry on:
Adapter SHOULD NOT retry blindly on:
Use exponential backoff with jitter.
Adapter errors MUST be normalized into stable error codes so the orchestrator can:
Example normalized error:
{
"error": {
"code": "PROVIDER_TIMEOUT",
"message": "Request timed out after 60s",
"retryable": true
}
}
If Grok provides usage metadata, the adapter SHOULD emit it in ProviderResult.usage.
If usage is not provided, SwarmCraft MAY estimate tokens separately, but should mark them as estimates.
Token tracking integrates with dashboard/cost panels:
The provider is invoked only during EXECUTE (and optional planning calls if you LLM-assist planning).
The pipeline remains:
Pipeline: Deterministic Pipeline