交易式AI:為可靠的AI代理工作流程實施Saga模式

交易式AI:為可靠的AI代理工作流程實施Saga模式

Hacker News·

本文介紹了交易式AI,一種用於AI代理的可靠性協議,它實施了Saga模式。該協議為長時間運行的LLM操作提供持久的回滾和狀態恢復功能,通過分布式鎖定和Postgres存儲等企業級功能,解決了AI代理常見的不穩定問題。

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

To see all available qualifiers, see our documentation.

License

Uh oh!

There was an error while loading. Please reload this page.

Grafikui/Transactional-ai

Folders and files

Latest commit

History

Repository files navigation

Transactional AI

A reliability protocol for AI Agents.
Implement the Saga Pattern with persistent rollback and state recovery for Long-Running Machine (LLM) operations.

Image

Image

Image

Why use this?

AI Agents are flaky. Steps fail, APIs time out, and hallucinations happen.
transactional-ai gives you:

Installation

Quick Start

1. The "Litmus Test" (Basic Usage)

Define a transaction where every action has a compensating rollback action.

Adding Persistence (Redis)

To survive process crashes, simply provide a storage adapter.

Enterprise Features (v0.2.0)

1. Distributed Locking (Redis)

Prevent race conditions when running multiple agent workers on the same Transaction ID.

2. Postgres Storage (SQL)

Use Postgres for strict ACID compliance and auditability.

Prerequisite: Run schema.sql in your database.

Before using PostgresStorage, create the required table in your database:

Option 1: Run the provided schema

Option 2: Copy-paste this SQL

Important: The table must exist before running your first transaction. It will NOT be auto-created.

3. Retry Policies

Handle flaky APIs (e.g., OpenAI 500 errors) automatically without failing the transaction.

4. Step Timeouts (NEW in v0.2.1)

Prevent steps from hanging indefinitely with configurable timeouts.

5. Observability Hooks (NEW in v0.2.1)

Integrate with your logging, metrics, and alerting systems using event hooks.

Available events:

See full example: npm run example:observability

CLI Inspector

You don't need a complex dashboard to see what your agents are doing. Use the included CLI to inspect transaction logs directly from your terminal.

Output:

Advanced Usage

Audit Mode (Governance)

By default, logs are cleared upon success to save storage space. To keep a permanent audit trail for compliance (e.g., "Why did the agent do this?"), enable Audit Mode:

Manual Rollbacks

The library handles rollbacks automatically on error. You can trigger them manually by throwing an error inside any step:

Testing Utilities (NEW in v0.2.1)

Write fast, isolated tests for your transaction workflows with built-in testing utilities.

Testing utilities:

Roadmap

[x] Core Saga Engine (Execute/Compensate)

[x] Persistence Adapters (File, Redis)

[x] Resumability (Skip completed steps)

[x] CLI Inspector (tai-inspect)

[x] Concurrent Transaction Locking

[x] Postgres/SQL Storage Adapter

[x] Step Retry Policies

[x] Step Timeouts (v0.2.1)

[x] Observability Event Hooks (v0.2.1)

[x] Testing Utilities (v0.2.1)

License

MIT

About

Resources

License

Uh oh!

There was an error while loading. Please reload this page.

Stars

Watchers

Forks

Releases

  2

Packages

  0

Languages

Footer

Footer navigation

Hacker News

相關文章

  1. 確保代理式AI基礎:無廢話指南 - 第一部分

    4 個月前

  2. 1Password 如何確保代理人架構的安全

    1password.com · 大約 2 個月前

  3. 構建可靠的AI代理

    3 個月前

  4. 我們在1973年解決了AI代理的信任問題(只是忘了)

    3 個月前

  5. HN 展示:UAIP Protocol – 自主 AI 代理的安全結算層

    3 個月前