Nicola Attico
ServiceNow Employee

This project explores a simple but insightful setup: two ServiceNow AI agents playing chess against each other.

 

The interaction is driven by an agent loop. Each move made by one agent triggers the next invocation, allowing the game to progress autonomously without external intervention.

 

Two Agents, Two Approaches

 

The two agents are intentionally designed with different capabilities:

 

  • Black player

    A baseline agent powered by a standard LLM and a simple prompt. It relies entirely on reasoning within the model.

  • White player

    A more advanced agent with:

     

    • A stronger, more structured prompt

    • Access to an external tool powered by Stockfish, a chess engine that evaluates positions and ranks candidate moves

     

This creates an interesting contrast between pure LLM reasoning and tool-augmented decision-making.

 

Observations

(10x speed match)

 

One of the key takeaways is that LLMs on their own are not particularly strong at chess.

 

They can:

 

  • Generate plausible moves

  • Follow basic rules of the game

 

But they often:

 

  • Struggle to maintain full board awareness as complexity increases

  • Miss tactical opportunities

  • Make inconsistent or suboptimal decisions

In practice, they behave more like beginner-level players.

 

 

The Key Insight

This setup highlights an important pattern when building AI agents for complex systems:

 

The agent’s strategy does not have to live entirely inside the LLM. It can emerge from the tools the agent uses.

 

By augmenting an LLM with structured tools (in this case, a chess engine), you can significantly improve performance without requiring a fundamentally stronger model.

 

 

Why Chess Works Well

 

Chess is a useful “sandbox” for experimenting with agent behavior because the ecosystem is well-supported and deterministic.

 

Key components used in this setup:

 

  • Chess.js

    Handles move generation, FEN/PGN parsing, legal move validation, and SAN conversion

  • Chessboard.js

    Provides board visualization

  • FEN (Forsyth–Edwards Notation)

    A compact string representation of the board state, making it easy to pass context between agents

  • Stockfish (via REST API)

    The only external component, used as a tool to evaluate and rank moves

 

Architecture Summary

 

 

  1. Current board state is represented as FEN

  2. Active agent receives the state and decides on a move

  3. Move is validated and applied

  4. Updated state is passed to the opposing agent

  5. Loop continues until the game ends

 

Why This Matters for ServiceNow AI

 

This pattern maps well to real-world enterprise scenarios:

 

  • LLMs provide reasoning and orchestration

  • Tools provide precision, domain expertise, and reliability

  • The combination produces more robust outcomes than either alone

Rather than trying to embed all intelligence in prompts, you can design agents that compose capabilities through tools.

 

Update sets + stockfish service

 

  • A fully autonomous chess game running entirely inside a ServiceNow scoped application (x_snc_scacchi)

  • Two AI agents play against each other move-by-move, with no human intervention required

  • Built to demonstrate the power of ServiceNow's AI Agent Studio (Now Assist) for agentic, multi-turn automation

  • A single Chess Player Agent (Now Assist AI agent) is reused for both sides, with different runtime objectives injected per turn via a structured output schema (next_movenext_fen_state, strategy)

  • ChessGameRunner Script Include orchestrates the full game loop: reads board state, calls Stockfish, builds the agent objective, invokes the agent, polls the execution plan, and applies the resulting move

  • A local Stockfish chess engine is exposed via ngrok and called via REST API — for White's turns, the top 5 engine-recommended moves with evaluations are embedded directly into the agent's prompt

  • chess.js is bundled as a Script Include for FEN/PGN parsing, legal move generation, capture annotation, and move validation

  • x_snc_scacchi_position stores the live board state (FEN, PGN, turn, game status); x_snc_scacchi_move stores every move with the agent's strategy reasoning

  • White gets Stockfish's top 5 moves, threat analysis, capture annotations, and previous strategy context — a rich engine-assisted prompt

  • Black gets only legal moves and basic capture annotations — no engine support, making it the underdog

  • A Jelly UI page renders a live chess board (chessboard.js + jQuery) that auto-refreshes every 3 seconds via the ServiceNow Table REST API, with a chat panel showing each agent's move and reasoning in real time

  • To run: start Stockfish locally, expose via ngrok, update the x_snc_scacchi.stockfish_endpoint system property, hit Reset state on the position record, then trigger the Play game Flow Designer action

PS: Please, reach out if you want to install the application (I'll need to share the update set separately) or discuss the prototype 😀