AI-Assisted Development
Patterns for using AI coding agents (Cursor, GitHub Copilot, custom agents) with the neops Worker SDK.
Why AI Works Well with neops
The SDK is designed with properties that make it particularly suitable for AI-assisted development:
- Typed interfaces — Pydantic parameters and results give AI models clear contracts to work with.
- Declarative registration — the
@register_function_blockdecorator provides structured metadata that AI can generate consistently. - Pattern consistency — every function block follows the same
acquire()/run()structure, making it easy for AI to learn the pattern from a single example. - JSON schemas — parameter and result schemas are auto-generated, providing machine-readable API descriptions.
Providing Context to AI Agents
When asking an AI agent to write function blocks, provide:
-
The base classes and their signatures:
-
An example function block — point the agent at
examples/getting-started/echo/echo.pyas a template. -
The registration decorator fields:
Field Required Purpose nameYes Unique identifier descriptionYes Human-readable description packageYes Package name versionNo Semantic version tuple (major, minor, patch), default(1, 0, 0)run_onYes Entity type: "device","group","interface", or"global"fb_typeYes Function block type param_clsYes Parameter Pydantic model class result_clsYes Result Pydantic model class is_pureNo No side effects (default False)is_idempotentNo Safe to retry (default False) -
The knowledge base documents in
.agent/knowledge/— these contain concise architecture summaries suitable for agent context windows.
Patterns for AI-Generated Function Blocks
Scaffold generation
Ask the agent to generate:
- Parameter and result Pydantic models
- The function block class with
acquire()andrun() - The registration decorator
- A matching test file
Network-specific prompts
Effective prompts for network automation:
- "Write a function block that collects BGP neighbor state from a device using the DeviceInfoCapability proxy and stores the result in device facts."
- "Write an idempotent function block that pushes an ACL configuration to a device. It should back up the current config first."
- "Write a pure function block that validates NTP configuration against a policy defined in the parameters."
Test generation
AI agents can generate tests from function block code:
- "Write a standalone pytest test for this function block using
create_workflow_contextwith mock device data." - "Add
@fb_test_casedecorators for success and failure paths."
Agent Knowledge Base
The .agent/knowledge/ directory contains markdown documents summarizing:
| Document | Content |
|---|---|
worker-sdk-architecture.md |
SDK structure, key modules, public API |
workflow-engine-architecture.md |
Workflow engine internals, job lifecycle |
neops-core-architecture.md |
CMS data models, GraphQL API |
remote-lab-architecture.md |
Remote lab service, topology provisioning |
neops-ecosystem-overview.md |
High-level system overview |
These are optimized for AI context windows — concise, structured, and focused on the information agents need to generate correct code.
Tips
- Start with parameters. Define the Pydantic models first — they constrain the function block's behavior and give the AI a clear contract.
- Reference real examples. Point to
examples/for patterns rather than describing them from scratch. - Validate with tests. Always generate a test alongside the function block and run it immediately.
- Use the type system. The SDK's type annotations help AI models generate
correct code. Avoid
Anytypes in parameters and results.