Logo Hor Agent Loop

Hor Agent Loop

Tổ chức
openreachtech
hor-agent-loop

Build an LLM agent loop (iterative agent) in a backend repository with the three @openreachtech/mentsu-agent-loop packages — core (the transport-agnostic iteration engine), renchan-job (run a loop as a BullMQ/Redis job with progress publishing), and graphql (a mutation that launches the loop plus a subscription that streams its progress). Use whenever the user asks to add or edit an agent loop, an agent action, a composite agent, or to stream agent progress.

Tổng quan

Nhà phát hànhopenreachtech
Kho mãhora-skills-ort-renchan
Tên kỹ nănghor-agent-loop
Sao
32
Bản fork
0
Tệp đi kèm
4
Giấy phépApache-2.0
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI là Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 4 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được openreachtech công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Hor Agent Loop trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/openreachtech/hora-skills-ort-renchan/tree/main/kit/skills/hor-agent-loop
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/openreachtech/hora-skills-ort-renchan.git /tmp/hora-skills-ort-renchan
mkdir -p .claude/skills
cp -r /tmp/hora-skills-ort-renchan/kit/skills/hor-agent-loop .claude/skills/hor-agent-loop
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Hor Agent Loop trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự tải Hor Agent Loop ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên Hor Agent Loop không bị giới hạn ở mô hình mà kỹ năng này được viết cho. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên kỹ năng chưa dùng không tốn chi phí.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Agent Loop (building agent loops with mentsu-agent-loop)

A skill for implementing an LLM agent's iteration ("loop") in a backend. The iteration engine, progress delivery, composition, job execution, and GraphQL integration are all provided by the three @openreachtech/mentsu-agent-loop-* packages. The app writes only the domain-specific actions and loops; iteration, stopping, compression, parallelism, and transport ride on the ready-made base classes.

This skill covers the libraries' specs and use cases, plus the integration patterns for renchan's GraphQL and renchan-job-bullmq. Always use these three packages (never hand-roll your own iteration engine, queue bridge, or progress channel). The details are split into the detail files at the end.

Grand principle: write actions and loops without knowing about AI, DB, queues, or GraphQL (one-way dependency)

The center of this package family's design is a one-way dependency direction (outer → core). The iteration logic the app writes (actions / loops) imports no business dependency and no transport; everything is reached through the context (an opaque DI seam) and through thin adapters.

LayerPackageResponsibilityDepends on
core@openreachtech/mentsu-agent-loop-coreIteration engine (Action / Loop / composition / Runner / Topic). Zero dependenciesimports nothing
job execution@openreachtech/mentsu-agent-loop-renchan-jobRun a loop as a renchan-job / BullMQ Redis job and publish progress→ core, renchan-job-bullmq
GraphQL@openreachtech/mentsu-agent-loop-graphqlLaunch mutation + progress-subscription→ core, renchan
app(this repository)Actions / loops / wiring→ all of the above
  • Why keep the dependency one-way: the moment core imports AI/DB/queue/transport, the iteration logic is bound to a specific backend and can no longer be tested in-process or switched between execution modes. Keeping core dependency-free and receiving dependencies from context means the same loop runs in-process or as a job, and tests just swap context for a stub.
  • Why write only actions and loops: the iteration body (the tail-recursive iterate), the progress seam (emitProgress), composition (parallel / sequential), the queue bridge, and channel naming are all shared machinery; writing them per app guarantees drift. Push them into the base classes and implement only the abstract hooks.
  • Why "always these three packages": hand-rolling an iteration engine or progress channel reintroduces known failures — publish/subscribe channel mismatch, no retry, untestable code. The packages prevent these by design (e.g. AgentTopic structurally matches the publish and subscribe channels).
  • Everything is an instance method, overridable via extends. No pure functions or static-only classes. Why: even if the library has a bug or a gap, the app can always work around it by extending and overriding the relevant method (there is no true final). Write the app's overrides in the same style.

Cross-cutting rules

  • Business dependencies and transport are always received through context. Do not directly import AI clients, DB, HTTP, or queues inside an action or loop (core.md). Why: a direct import breaks in-process execution and stub injection, collapsing the one-way dependency of the grand principle.
  • Return null / an empty array for missing values, not undefined. One property per line in object literals (applies to sample code too). Avoid single-character variables and for / forEach / switch / else if; write with map / filter / reduce and early return. Why: match the existing codebase style so review attention goes to the logic.
  • One class per file, one export default. The constructor only assigns; defaults live in the factory (static create); getters just return the field.
  • Comments in produced artifacts (.js) are English, and this skill is written entirely in English (prose, tables, and example-code comments).

Choosing modules (what to install)

Stack adapters onto core per the requirement. Core is always required; add an adapter only when that integration is needed.

What you wantPackages needed
Run a loop in-process (CLI / tests / synchronous work / Lambda)core only
Turn a long loop into a Redis job (horizontal scale, retry, rate limiting)core + renchan-job
Launch over GraphQL and subscribe to progress in realtimecore + renchan-job + graphql
  • Why stack incrementally: actions and loops written with core alone can be turned into a job or a GraphQL endpoint without any change (the adapter swaps only the transport step). Do not install everything up front; layer on only what you need.

End-to-end progress (the backbone of the realtime log)

"Launch with a mutation → return accepted immediately → stream progress over a subscription" is the typical shape for an agent on the web. Progress follows this single path. Because the publish side (the Worker) and the subscribe side (the Subscription) use the same AgentTopic, the channel names match structurally.

[core]        loop.run({ input, onProgress })
                └ iterate emits emitProgress → onProgress(event) each iteration
[renchan-job] BaseAgentJobWorker: onProgress → job.updateProgress(event)
                → onJobProgress → publish to the channel AgentTopic.create({ channel, scope }).value
[graphql]     BaseAgentProgressSubscriptionResolver: subscribes to the same channel + scope
[frontend]    receives it in realtime over a GraphQL Subscription
  • Why use AgentTopic on both sides: if the publish and subscribe channel names drift apart, you get a silent "progress never arrives" failure. Concentrating the naming in one core class, with both sides composing from the same channel + scope, makes drift impossible by design. To change the naming rule, extend AgentTopic and override get value() in one place.

Detail files

  • core.md — the core (@openreachtech/mentsu-agent-loop-core) spec and use cases: actions / registry, the two loop types (AI-driven / procedural), composition (parallel Composite / sequential Pipeline / ActionStage), Runners, AgentTopic / AgentProgressEvent, the state model (state / context / compression).
  • graphql-integration.md — the pattern for integrating with renchan's GraphQL: the launch mutation (BaseRequestAgentMutationResolver) and the progress subscription (BaseAgentProgressSubscriptionResolver), channel matching via AgentTopic.
  • renchan-job-integration.md — the pattern for integrating with renchan-job-bullmq: the Worker (BaseAgentJobWorker) / Dispatcher (BaseAgentJobDispatcher) / JobAgentRunner, Engine / Share / Context wiring, concurrency / limiter, and the full progress-publish flow.
  • testing.md — testing guidelines: the contract test kit (LoopContractAssertion / ActionContractAssertion) and the unit-test approach for actions / loops / composition / Worker / Dispatcher / Resolver (stub context, assert onProgress, assert abstract throws).

Tệp đi kèm

Mô hình đọc các tệp này khi cần trong lúc kỹ năng được tải. Các tệp được cung cấp ở dạng có thể đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Hor Agent Loop làm được gì?

Build an LLM agent loop (iterative agent) in a backend repository with the three @openreachtech/mentsu-agent-loop packages — core (the transport-agnostic iteration engine), renchan-job (run a loop as a BullMQ/Redis job with progress publishing), and graphql (a mutation that launches the loop plus a subscription that streams its progress). Use whenever the user asks to add or edit an agent loop, an agent action, a composite agent, or to stream agent progress.

Vì sao nên dùng Hor Agent Loop trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Hor Agent Loop là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Hor Agent Loop trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/openreachtech/hora-skills-ort-renchan/tree/main/kit/skills/hor-agent-loop. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm và cài đặt thành một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Hor Agent Loop?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Bạn có thể dùng Hor Agent Loop với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Hor Agent Loop với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Hor Agent Loop có miễn phí không?

Có. Kỹ năng này được openreachtech phát hành trên GitHub theo giấy phép Apache-2.0. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp cho mô hình các công cụ mới để gọi — mã được chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và tiêu chí của đầu ra tốt. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇