Agent Service Chat Task¤
task api name:
invoke
Invokes an Agent worker with user instructions. The task is commonly used as an interactive chat surface, but the API task name is invoke.
Select the built-in NorFab agent or supply an nf:// or git:// YAML definition
as name. See inventory and definitions.
Each call starts a fresh conversation; there is no conversation thread setting.
Output¤
By default, returns the final agent response text. With verbose_result=True, returns the full agent invocation payload.
Examples¤
Ask the default agent a question:
nf# agent invoke instructions "Summarize the current NorFab inventory"
Invoke a custom agent:
nf# agent invoke name nf://agents/interface_check.yaml instructions "Check interfaces on r1"
Context manager:
from norfab.core.nfapi import NorFab
with NorFab(inventory="./inventory.yaml") as nf:
client = nf.make_client()
result = client.run_job(
service="agent",
task="invoke",
workers="any",
kwargs={
"instructions": "Summarize the current NorFab inventory",
},
)
print(result)
Direct lifecycle with a named agent:
from norfab.core.nfapi import NorFab
nf = NorFab(inventory="./inventory.yaml")
try:
nf.start()
client = nf.make_client()
result = client.run_job(
service="agent",
task="invoke",
workers="any",
kwargs={
"name": "NorFab",
"instructions": "Check whether any workers are unhealthy",
"verbose_result": True,
},
)
print(result)
finally:
nf.destroy()
NORFAB Agent Chat Command Shell Reference¤
NorFab shell supports these command options for Agent invoke task:
nf# man tree agent
root
└── agent: AI Agent service
├── timeout: Job timeout
├── workers: Filter worker to target, default 'all'
├── show: Show Agent service parameters
│ ├── inventory: show agent inventory data
│ ├── version: show agent service version report
│ └── status: show agent status
├── invoke: Invoke an agent to chat or run a task
│ ├── instructions: Provide instructions
│ ├── name: Agent name to interact with
│ └── progress: Emit execution progress, default 'True'
└── progress: Emit execution progress, default 'True'
nf#
Python API Reference¤
Run instructions with the built-in agent or a custom YAML definition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job
|
Job
|
Job context used to report execution progress. |
required |
instructions
|
str
|
Request sent to the agent. |
required |
name
|
str
|
|
'NorFab'
|
verbose_result
|
bool
|
Return the full agent invocation payload when true; otherwise return the final response content. Defaults to false. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
Result |
Result
|
Final response content or the full invocation payload. Each invocation starts a fresh conversation without stored history. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
The built-in agent has no configured |
FileNotFoundError
|
The custom definition cannot be fetched. |
KeyError
|
A required definition or fallback model setting is missing. |
Source code in norfab\workers\agent_worker\agent_worker.py
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 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | |