展示HN:UltraContext – 具有自动版本控制的AI代理的简单上下文API
Show HN: UltraContext – A simple context API for AI agents with auto-versioning

原始链接: https://ultracontext.ai/

``` 1import { UltraContext } from 'ultracontext' 2const uc = new UltraContext({ apiKey: 'uc_...' }) 3 4// 构建对话历史(无模式) 5await uc.append('ctx_123', { role: 'user', content: '...' }) 6await uc.append('ctx_123', { role: 'assistant', content: '...' }) 7 8// 对现有消息的更改会创建版本 9await uc.update('ctx_123', { id: 'msg_1', content: '更新的系统提示' }) // v2 10 11// 回滚和从任何点分支 12const { data } = await uc.get('ctx_123', { version: 0 }) 13const branch = await uc.create({ from: 'ctx_123', version: 1 }) 14 15// 与任何 LLM 框架一起使用 16const response = await generateText({ model, messages: data }) ```

## UltraContext:AI 代理上下文管理 UltraContext (ultracontext.ai) 是一种新的 API,旨在简化 AI 代理的上下文管理,解决扩展和调试代理行为的难题。它受到 Git 的启发,为所有上下文变更(更新、删除甚至分支)提供自动版本控制,允许开发者重现代理状态并轻松调试问题。 该 API 提供五个核心方法:`create`、`append`、`get`、`update` 和 `delete`,处理无模式的消息存储,用于对话历史记录、工具调用和系统提示。它旨在用于持久化状态、调试、测试不同的代理流程以及构建审计跟踪。 重要的是,UltraContext *不是* 记忆/RAG 系统或编排框架;它专注于版本控制和历史记录。虽然会增加少量 (~20 毫秒) 延迟,但它旨在通过消除从头开始构建复杂上下文基础设施的需求来节省开发者的时间。创建者正在寻求反馈,特别是来自具有上下文工程经验的人员。
相关文章

原文

1import { UltraContext } from 'ultracontext'

2const uc = new UltraContext({ apiKey: 'uc_...' })

3

4// Build conversation history (schemaless)

5await uc.append('ctx_123', { role: 'user', content: '...' })

6await uc.append('ctx_123', { role: 'assistant', content: '...' })

7

8// Changes to existing messages create versions

9await uc.update('ctx_123', { id: 'msg_1', content: 'Updated system prompt' }) // v2

10

11// Rollback and branch from any point

12const { data } = await uc.get('ctx_123', { version: 0 })

13const branch = await uc.create({ from: 'ctx_123', version: 1 })

14

15// Use with any LLM framework

16const response = await generateText({ model, messages: data })

联系我们 contact @ memedata.com