Agentic Workers
Konten ini belum tersedia dalam bahasa Anda.
An agentic worker is an LLM-driven Plan → Act → Observe loop with tools, exposed to a flow as a single node. Instead of hand-wiring every step, you give the worker a goal (system prompt) and a set of tools; the model decides which tools to call, observes the results, and keeps going until it can answer.
This guide shows how to build one by hand and run it end to end. (Code identifiers use
dw_* / dw.agent — the runtime name for what the product calls an “Agentic Worker”.)
A worker comes in one of three shapes — see Agent Types for
single_turn (this guide), agent_graph, and deep_worker. Workers can also carry
memory and a knowledge corpus.
The pipeline
Section titled “The pipeline” Designer / by hand Packaging Runtime (gtc start)┌──────────────────┐ ┌───────────────┐ ┌──────────────────────────┐│ AgentConfig │ │ worker → pack │ │ flow .ygtc ││ + tool extension │ → │ tools → .gtxpack │ → │ └ dw.agent node ││ + a flow │ │ │ │ └ AgentRuntime loop │└──────────────────┘ └───────────────┘ │ LLM ⇄ tools │ └──────────────────────────┘A worker has three pieces:
- An
AgentConfig— the system prompt, the allowed tools, the LLM provider/model, limits, and optionalguardrails,memory, andknowledgeblocks. - Its tools — either a
.gtxpackdesign-extension (the same format ascomponent-tavily-ext), discovered at runtime, or an MCP server registered for the tenant. - A flow with a single
dw.agentnode that hands user messages to the worker.
1. The agent config
Section titled “1. The agent config”The worker’s behaviour is one JSON document (schema: greentic-aw-runtime’s AgentConfig).
Save it as <agent_id>.json in GREENTIC_AGENT_MANIFESTS_DIR (default ~/.greentic/agents):
{ "agent_id": "tx-network-assistant", "system_prompt": "You are a read-only network operations assistant. Resolve an entity (prefix, device) before analysing it, then call the matching analysis tool. Never invent data; if a tool returns found=false, ask the user to clarify.", "tools": [ { "extension_id": "greentic.telco-x-tools", "tool_name": "tx_resolve_prefix" }, { "extension_id": "greentic.telco-x-tools", "tool_name": "tx_analyse_top_source_asns" } ], "llm": { "provider": "openai", "model": "gpt-4o-mini" }, "limits": { "max_iter": 8 }}tools[]is the allow-list:extension_idis a loaded extension’s id,tool_nameis one of its tools. Only listed tools are exposed to the model.limits.max_iterbounds the loop (default 8) — enough for multi-step resolve-then-analyse investigations.llmaccepts any greentic-llm provider —openai,anthropic,deepseek,gemini, and the others — as{ "provider": "...", "model": "...", "credential_ref": "..." }. Usecredential_refto name a stored credential instead of relying on an environment variable.- The config also supports optional
guardrails(see below),memory, andknowledgeblocks. Omit them to start simple.
2. The tool extension
Section titled “2. The tool extension”Package your tools as a design-extension .gtxpack. The quickest start is to copy
component-tavily-ext and replace the tool logic. Each
tool must declare the agentic_worker capability in its tool_meta:
ToolMeta { name: "tx_resolve_prefix", description: "Resolve a network prefix to its canonical id.", input_schema_json: RESOLVE_PREFIX_INPUT, output_schema_json: RESOLVE_PREFIX_OUTPUT, capabilities: vec!["agentic_worker".into()], // ← required to be an agent tool agentic_worker_metadata: RESOLVE_PREFIX_AW_META,}Build and stage it where the runtime discovers extensions:
bash build.sh # → greentic.telco-x-tools-1.0.0.gtxpack# Stage into the design kind-dir the runtime scans at boot:unzip -o greentic.telco-x-tools-1.0.0.gtxpack \ -d "$GREENTIC_EXTENSIONS_DIR/design/greentic.telco-x-tools"3. The flow
Section titled “3. The flow”A dw.agent node maps the inbound message to user_text and routes the reply back. The
node key is dw.agent.<agent_id>:
id: network_assistant_flowtitle: Network Assistanttype: messagingschema_version: 2start: ask_agent
nodes: ask_agent: dw.agent.tx-network-assistant: # component=dw.agent, operation=agent_id input: mapping: '{"user_text": "{{in.text}}"}' routing: reply- Input contract: the node payload must contain
user_text. - Output contract: the worker returns
{ reply, trail, terminated_by };routing: replysendsreplyback over the inbound channel.
4. Run it
Section titled “4. Run it”The runtime needs a state backend (in-memory by default — no Redis required), an LLM key, and the extension + manifest staged:
# State backend is optional: unset → in-memory (ephemeral). For durability use# `export GREENTIC_AW_STATE_BACKEND=disk` (on-disk redb) or point at Redis for# multi-instance state: `export GREENTIC_AW_REDIS_URL=redis://127.0.0.1:6379`export OPENAI_API_KEY=sk-... # or GREENTIC_LLM_API_KEYexport GREENTIC_EXTENSIONS_DIR=~/.greentic/extensionsexport GREENTIC_AGENT_MANIFESTS_DIR=~/.greentic/agents
gtc start ./my-bundle --cloudflared off --nats onA message arrives → the flow routes it to the dw.agent node →
AgentRuntime::step(tenant, session, agent_id, text) runs the loop → the reply goes back to
the user. A typical two-step investigation:
USER: What are the top source ASNs for prefix 10.0.0.0/8? turn 1: model calls tx_resolve_prefix{"query":"10.0.0.0/8"} → {prefix_id: "px-core-10-8"} turn 2: model calls tx_analyse_top_source_asns{"prefix_id":"px-core-10-8"} → ranked ASNs turn 3: model writes the final answerWORKER: The top source ASNs for 10.0.0.0/8 are: AS15169 (Google) 4.2 Gbps (38.1%), …Guardrails
Section titled “Guardrails”A worker can run guardrails — content-safety hooks that fire on every step at two points:
inbound (the user prompt, before the LLM sees it) and outbound (the LLM reply, before
it reaches the caller). Each guardrail returns one of three verdicts — accept (pass
through), update (replace with masked/rewritten content), or deny (block with a
structured payload). Guardrails are chained in order; an update feeds the modified content
to the next guardrail.
Declare agent-level guardrails in AgentConfig.guardrails by capability id, e.g.:
"guardrails": ["greentic:guardrail/pii"]Agent-level guardrails fail open (skipped if unresolvable); platform/tenant mandatory
guardrails injected by policy fail closed (block if unresolvable). Each guardrail is a
design extension implementing greentic:extension-design/guardrail@0.3.0. See
Guardrail Extensions for authoring and the reference
component-guardrail-pii implementation.
Worked example
Section titled “Worked example”A complete, runnable agentic worker lives in the Telco-X solution repo under
bundles/agentic-network-assistant/ (worker config, a four-tool extension in
extensions/network-tools-ext/, the flow, and a run.sh that stages everything). Its
docs/agentic-workers-integration.md walks through the same pieces with file references.
Reference
Section titled “Reference”| Variable | Purpose |
|---|---|
GREENTIC_AW_STATE_BACKEND | State backend: redis | memory | disk. Unset → redis if GREENTIC_AW_REDIS_URL is set, else memory (ephemeral). memory/disk = single-process locking only. |
GREENTIC_AW_STATE_PATH | On-disk (redb) path when GREENTIC_AW_STATE_BACKEND=disk (default ~/.greentic/aw-state.redb). |
GREENTIC_AW_REDIS_URL | Optional. Redis worker conversation state + idempotency for durable / multi-instance state. Unset → in-memory backend (worker still runs). |
GREENTIC_LLM_API_KEY / OPENAI_API_KEY | LLM credential. |
GREENTIC_LLM_PROVIDER / GREENTIC_LLM_MODEL | Override provider/model. |
GREENTIC_EXTENSIONS_DIR | Tool-extension discovery root (scans <root>/design/). |
GREENTIC_AGENT_MANIFESTS_DIR | <agent_id>.json config dir. |
GREENTIC_EXT_ALLOW_UNSIGNED | Allow unsigned extensions (dev only; needs the dev feature). |