Urgent.News

What's breaking now, across thousands of outlets.

Tech

Running a Python or LangGraph Agent as a Flisk Worker, With Dependencies Declared

Not every agent answers HTTP requests. Some work through a queue: they pick up a task, call a model, write a result, and wait for the next one. Flisk's worker resource type fits that shape. The docs describe a Python or LangGraph agent running as a worker, with Postgres and NATS declared as dependencies. Scaffold the worker flisk resource research-agent --type worker --stack shop --yes Then…

A worker agent operates differently from HTTP-response agents. It utilizes a queue system, acquiring tasks, executing them via a model, and outputting results. The Flisk worker resource aligns with this architecture, necessitating Postgres and NATS services as dependencies. To set up the worker, initiate a scaffolded flisk resource named research-agent with a worker type, targeted at the shop stack, using the --yes flag for automation.

The service.json file must specify the worker's name, type, stack, and dependencies: Postgres and NATS. Connection strings for these services are referenced using @ref(...) within the environment block, preventing hard-coded URLs and ensuring flexibility.

The worker's boot sequence is contingent on the readiness of Postgres and NATS, as stipulated in the docs. This sequencing is crucial to prevent startup races, where a premature worker might fail during its initial poll due to an unready queue. Additionally, the worker demonstrates resilient behavior during hot reloads, seamlessly reconnecting. This characteristic should be validated within the operational setup, given that the reconnection logic resides within the agent's codebase.

For optimal functionality, the worker must be designed to be idempotent. This means that executing the same task twice should not result in duplicate actions, such as sending multiple emails or recording redundant database entries. Employing the task ID as a unique identifier helps prevent such duplications. Logging each task execution with its corresponding ID provides a clear audit trail.

In the event of a task failure, a defined retry limit should be enforced. Once exhausted, the task should transition to a failed state, preserving the error information for future reference.

It's important to differentiate a worker from a session server, as the latter does not support x-session-id routing due to the absence of conversational continuity in queue-based interactions. If a session continuity feature is required, the agent resource is the more suitable choice, as detailed in the preceding article of this series.

In essence, a background agent aligns with the worker resource model. The dependencies, namely Postgres and NATS, must be declared under dependsOn, with their URLs referenced via @ref(...) to maintain configuration agility. Ensuring the task handling is idempotent, imposing a cap on retry attempts, and confirming the start order through a dry run before deployment are essential steps to ensure the worker's reliability and efficiency.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Flisk as a Control Plane: Let Your Coding Assistant Run the Whole Local Stack

The mcp resource puts an agent's tools inside your stack. The flisk mcp command does the reverse: it lets an assistant control the stack.

  • Flisk MCP enables coding assistants to control local development stack
  • Assistant can check status, start services, read statuses, fetch logs
  • Restrict assistant access to sensitive operations like volume deletion

Flisk MCP Resources: Give Your Agents Tools That Run Next to Your Services

Agents are only as useful as the tools they can call. An mcp resource in Flisk is a Model Context Protocol server that runs in the same local stack as your services.

  • Flisk MCP Resources offer tools running alongside services in a single local stack.
  • MCP server built with Docker, launched by flisk up, routed via Traefik.
  • Server includes health check at /health, placeholder tool named echo.

Flisk's Agent Resource: Durable Agents With Sessions You Can Restart

An agent is a process that holds a conversation. Restart the process and the conversation can disappear, unless something saves it. Flisk's agent resource type is built for that case.

  • Flisk offers durable agents with session-aware conversations
  • Conversation preserved through durable checkpoints during restarts
  • Traefik routing by session ensures separate concurrent conversations

How Flisk Routes Agent Traffic: A Sequence Diagram of One Turn

The earlier articles covered the agent, the MCP resource, and the control plane. This one follows a single turn: one request from a client to an agent, through the gateway, the checkpoint store, and…

  • Client sends POST request with session ID to gateway
  • Agent loads or creates session checkpoint from store
  • Agent appends user input to checkpoint and processes with model

How 3D Vision Lets Painting Robots Program Themselves

Painting a part with a robot used to start with a long teaching session. A programmer would guide the arm through each pass, save every waypoint, and then adjust the spray by trial and error.

  • 3D vision technology enables robots to autonomously program painting tasks.
  • Depth camera or laser scanner captures part as point cloud within seconds.
  • Software refines point cloud, identifies surfaces for coating without CAD files.

More from Saturday 24 October →