Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/wangtingyeye/llm-agent-study/gradiogit clone --depth 1 https://github.com/WangTingYeYe/llm-agent-studyWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.00507 |
| Opus 5 | $0.00000 | $0.00253 |
| Sonnet 5 | $0.00000 | $0.00101 |
| Haiku 4.5 | $0.00000 | $0.00051 |
Grade A, and why
gradio scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
What it actually says
description: 该规则解释了 Gradio 机器学习模型部署和客户端调用的约定和最佳实践。 globs: **/*.py alwaysApply: false
Gradio 规则
客户端使用规范
- 使用
gradio_client库而非完整的gradio包以获得更轻量级的体验 - 安装命令:
pip install gradio_client - 使用
Client类连接到 Gradio 应用:client = Client("app_url")
API 调用规范
- 使用
client.predict()进行阻塞式 API 调用,直接获取结果 - 使用
client.submit()进行非阻塞式调用,返回 Job 对象用于后台处理 - 文件参数使用
file()函数包装:file("path/to/file") - API 调用时使用与原应用相同的关键字参数名称
流式处理规范
- 对于流式输出,使用
submit()方法并迭代结果:
for result in client.submit("prompt"):
print(result)
错误处理规范
- 确保上游应用设置
show_error=True或使用gr.Error异常 - 客户端会抛出与上游应用相同的异常
- 使用适当的异常处理机制捕获和处理错误
作业管理规范
- 使用
job.status()检查作业状态和队列位置 - 使用
job.done()检查作业是否完成 - 支持作业取消和队列状态监控
- 在长时间运行的任务中定期检查作业状态
部署和集成规范
- 客户端可在任何 Python 环境中运行(包括 Flask、Django 等)
- 支持 Hugging Face Spaces 以及自定义服务器
- 在生产环境中使用时考虑认证和安全性
- 使用合适的超时设置避免长时间阻塞
最佳实践
- 对于生产应用,使用非阻塞的
submit()方法 - 实现适当的重试机制处理网络问题
- 在多线程环境中注意客户端的线程安全性
- 缓存客户端实例避免重复连接开销
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2d ago First seen · 61 lines · 0 tokens per session scan A 1d95c326b398
gradio is a cursor rule published in the GitHub repository WangTingYeYe/llm-agent-study (4 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 507 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other cursor rules, from other repositories
angular-20
This rule provides comprehensive best practices and coding standards for Angular development, focusing on modern TypeScript, standalone components, signals, and performance optimizations.
dev-standard
Apache Superset development standards and guidelines for Cursor IDE.
coolify-ai-docs
Master reference to all Coolify AI documentation in .ai/ directory.
typescript
Changes to these high-fan-out internals can affect every message, delta, element, or rerun. Keep work in them minimal, and benchmark changes with representative stress-test apps.
python_lib
Tips and guidelines specific to the development of the Streamlit Python library, not applicable to scripts and e2e tests.
specs
This directory contains product and tech specs for Streamlit features.