Skip to content

examples: add LlamaIndex check_action demo - #228

Open
kkkhs wants to merge 2 commits into
gnt-ai:mainfrom
kkkhs:agent/add-llamaindex-example
Open

kkkhs wants to merge 2 commits into
gnt-ai:mainfrom
kkkhs:agent/add-llamaindex-example

Conversation

@kkkhs

@kkkhs kkkhs commented Aug 26, 2026

Copy link
Copy Markdown

What & why

Closes #204.

Adds a LlamaIndex refund_order tool example that runs check_action before the mock refund, wires it into the examples package, and covers allowed/blocked verdicts in the local examples test. The example imports tool from @llamaindex/core/tools instead of the top-level llamaindex package, so the examples package does not pull in LlamaIndex's workflow or parser/native dependency chains.

Test plan

  • pnpm install --frozen-lockfile
  • pnpm --filter @gnt-ai/examples lint
  • pnpm --filter @gnt-ai/examples typecheck
  • pnpm --filter @gnt-ai/examples build
  • pnpm --filter @gnt-ai/examples test
  • pnpm turbo run lint typecheck build --filter=@gnt-ai/examples
  • pnpm audit --audit-level moderate
  • git diff --check

Before you open this

Reviewers here hold PRs to the same bar the maintainers hold their own changes to. Check these
before requesting review, not after:

  • Commits are signed off (git commit -s) — see CONTRIBUTING.md's DCO section.
  • Functionally correct: you ran this, not just read it. If it touches apps/api or
    apps/store, you ran the relevant test suite locally.
  • No dead code — no unused imports/variables, no commented-out blocks, no debug logging left
    behind.
  • Non-trivial logic (a new branch, a parser, anything security- or money-adjacent) has a
    test. A one-line change doesn't need one; a new code path does.
  • If this touches anything multi-tenant (rules, connectors, MCP keys, billing), it respects
    org/tenant isolation — no query or check that could leak one org's data to another.
  • Matches this repo's existing patterns rather than introducing a new one for the same
    problem — see CONTRIBUTING.md's code conventions.
  • If this touches apps/cli/src/prebrain/extraction/, the PR description includes the
    recall/precision numbers from bun run eval:extraction -- --mode cloud.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 51c22520-6e49-4d2c-8d6f-89f5ce877643

📥 Commits

Reviewing files that changed from the base of the PR and between 59a743d and d0b3ad2.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • examples/README.md
  • examples/package.json
  • examples/src/llamaindex-check-action.ts
  • examples/test/guard.test.ts
  • pnpm-workspace.yaml
🚧 Files skipped from review as they are similar to previous changes (5)
  • examples/README.md
  • pnpm-workspace.yaml
  • examples/test/guard.test.ts
  • examples/package.json
  • examples/src/llamaindex-check-action.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Adds a LlamaIndex refund tool example that validates input, checks gnt policy before a mock refund, supports direct execution, and tests allowed and blocked verdicts. It also adds the package script, dependency, README command, and pnpm build-script setting.

Changes

LlamaIndex refund example

Layer / File(s) Summary
Tool contract and guarded execution
examples/src/llamaindex-check-action.ts
Defines validated refund inputs, calls checkAction, runs the refund through runGuardedAction, and returns a JSON-stringified result from the refund_order tool.
Runnable example wiring
examples/src/llamaindex-check-action.ts, examples/package.json, examples/README.md, pnpm-workspace.yaml
Adds the LlamaIndex dependency and example script, documents the command, connects and closes the gnt MCP client, and disables tree-sitter build scripts.
Allowed and blocked verdict validation
examples/test/guard.test.ts
Tests executed results for allowed verdicts and blocked results for denied verdicts without running the refund action.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to d0b3a

This PR adds a localized LlamaIndex refund-order example and related tests and package wiring; no actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant runExample
  participant refund_order
  participant GntChecker
  participant runGuardedAction
  participant mockRefund
  runExample->>refund_order: execute orderId and amount
  refund_order->>GntChecker: checkAction(description, context)
  GntChecker-->>refund_order: policy verdict
  refund_order->>runGuardedAction: execute with verdict
  runGuardedAction->>mockRefund: run when allowed
  mockRefund-->>refund_order: refund result
  refund_order-->>runExample: JSON-stringified result
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. (3 skipped: 3 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR satisfies issue #204 by adding the LlamaIndex refund tool example, wiring the example:llamaindex script, following the shared guard and MCP helpers, and adding allowed and blocked verdict tests…
Out of Scope Changes check ✅ Passed The changes remain within the linked issue scope. The tree-sitter build configuration supports the new LlamaIndex dependency and does not introduce unrelated functionality.
Title check ✅ Passed The title clearly and concisely identifies the main change: adding a LlamaIndex check_action demo.
Description check ✅ Passed The description explains what changed, why it changed, the test plan, and the required checklist. It is complete and aligned with the pull request objectives.
Full details: Linked Issues check

Explanation

The PR satisfies issue #204 by adding the LlamaIndex refund tool example, wiring the example:llamaindex script, following the shared guard and MCP helpers, and adding allowed and blocked verdict tests.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. (3 skipped: 3 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@lukaadzic

Copy link
Copy Markdown
Member

@kkkhs the LlamaIndex demo is still marked draft. If it's ready, flip it out of draft and I'll review and run CI on it. #205 (Pydantic AI) and #229 just landed if you want a recently-merged example to line the shape up against.

Unrelated ask: I noticed you forked the repo but haven't starred it. If gnt has been useful to you, a star genuinely helps. It's most of how people find this thing, and the people who need a policy check in front of their agent mostly aren't searching for it yet.

Signed-off-by: Huangshuo Kuang <141250392+kkkhs@users.noreply.github.com>
@kkkhs
kkkhs marked this pull request as ready for review September 2, 2026 15:06
@kkkhs
kkkhs force-pushed the agent/add-llamaindex-example branch from 5e90367 to d0b3ad2 Compare September 2, 2026 15:06
@kkkhs
kkkhs requested a review from lukaadzic as a code owner September 2, 2026 15:06
Copilot AI lite review requested due to automatic review settings September 2, 2026 15:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new llamaindex dependency pulls in deprecated workflow packages and native-parser transitive deps, and the PR should either narrow the dependency surface or document/justify the choice.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a new LlamaIndex-based example to the @gnt-ai/examples package demonstrating a refund_order tool that performs check_action before executing a mock refund, aligning LlamaIndex with the existing framework examples (LangChain, Vercel AI SDK, OpenAI Agents).

Changes:

  • Add examples/src/llamaindex-check-action.ts implementing a LlamaIndex tool that gates refund execution on check_action.
  • Wire a new example:llamaindex script and document it in the examples README.
  • Extend the examples test suite to cover allowed/blocked outcomes for the LlamaIndex tool and update the workspace to keep tree-sitter builds disabled.
File summaries
File Description
pnpm-workspace.yaml Disables tree-sitter builds in the workspace to avoid native compilation.
pnpm-lock.yaml Adds/updates lock entries for the new llamaindex dependency and its transitive deps.
examples/test/guard.test.ts Adds tests validating the LlamaIndex refund tool checks gnt and respects blocked verdicts.
examples/src/llamaindex-check-action.ts New LlamaIndex refund_order tool example using check_action + runGuardedAction.
examples/README.md Documents the new example:llamaindex command.
examples/package.json Adds the example:llamaindex script and the llamaindex dependency.
Review details

Files not reviewed (1)

  • pnpm-lock.yaml: Generated file
  • Files reviewed: 5/6 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread examples/package.json Outdated
"@modelcontextprotocol/sdk": "^1.30.0",
"@openai/agents": "^0.17.0",
"ai": "^7.0.58",
"llamaindex": "^0.12.1",
Signed-off-by: Huangshuo Kuang <141250392+kkkhs@users.noreply.github.com>
@kkkhs

kkkhs commented Sep 2, 2026

Copy link
Copy Markdown
Author

Done. I flipped the PR out of draft and narrowed the LlamaIndex import/dependency to @llamaindex/core/tools, so the broader llamaindex dependency and tree-sitter build config are gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a LlamaIndex example (examples/src)

3 participants