response-compliance

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

OpenResponses Compliance Test

OpenResponses 合规测试

Run the official OpenResponses compliance test suite against the local (or remote) Response API endpoint.
对本地(或远程)Response API端点运行官方OpenResponses合规测试套件。

Quick Start

快速开始

bash
undefined
bash
undefined

From the openapi package directory

From the openapi package directory

cd lobehub/packages/openapi
cd lobehub/packages/openapi

Run all tests (dev mode, localhost:3010)

Run all tests (dev mode, localhost:3010)

APP_URL=http://localhost:3010 bun run test:response-compliance --
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1
APP_URL=http://localhost:3010 bun run test:response-compliance --
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1

Run specific tests only

Run specific tests only

APP_URL=http://localhost:3010 bun run test:response-compliance --
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1
--filter basic-response,streaming-response
APP_URL=http://localhost:3010 bun run test:response-compliance --
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1
--filter basic-response,streaming-response

Verbose mode (shows request/response details)

Verbose mode (shows request/response details)

APP_URL=http://localhost:3010 bun run test:response-compliance --
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1 -v
APP_URL=http://localhost:3010 bun run test:response-compliance --
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1 -v

JSON output (for CI)

JSON output (for CI)

APP_URL=http://localhost:3010 bun run test:response-compliance --
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1 --json
undefined
APP_URL=http://localhost:3010 bun run test:response-compliance --
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1 --json
undefined

Prerequisites

前置要求

  • Dev server running with
    ENABLE_MOCK_DEV_USER=true
    in
    .env
  • The
    api/v1/responses
    route registered (via
    src/app/(backend)/api/v1/[[...route]]/route.ts
    )
  • 开发服务器已运行,且
    .env
    中配置了
    ENABLE_MOCK_DEV_USER=true
  • 已注册
    api/v1/responses
    路由(通过
    src/app/(backend)/api/v1/[[...route]]/route.ts

Auth Modes

认证模式

ModeFlags
Dev (mock user)
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1
API Key
--api-key lb-xxxxxxxxxxxxxxxx
Custom
--auth-header <name> --api-key <value>
模式标识参数
开发(模拟用户)
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1
API Key
--api-key lb-xxxxxxxxxxxxxxxx
自定义
--auth-header <name> --api-key <value>

Test IDs

测试ID

Available
--filter
values:
IDDescriptionRelated Issue
basic-response
Simple text generation (non-streaming)LOBE-5858
streaming-response
SSE streaming lifecycle + eventsLOBE-5859
system-prompt
System role message handlingLOBE-5858
tool-calling
Function tool definition + call outputLOBE-5860
image-input
Multimodal image URL content
multi-turn
Conversation history via input itemsLOBE-5861
可用的
--filter
参数值:
ID描述关联Issue
basic-response
简单文本生成(非流式)LOBE-5858
streaming-response
SSE流式生命周期 + 事件LOBE-5859
system-prompt
系统角色消息处理LOBE-5858
tool-calling
函数工具定义 + 调用输出LOBE-5860
image-input
多模态图片URL内容
multi-turn
基于输入项的对话历史LOBE-5861

Environment Variables

环境变量

VariableDefaultDescription
APP_URL
http://localhost:3010
Server base URL (auto-appends
/api/v1
)
API_KEY
API key (alternative to
--api-key
flag)
变量名默认值说明
APP_URL
http://localhost:3010
服务端基础URL(自动拼接
/api/v1
API_KEY
API密钥(可替代
--api-key
参数)

How It Works

工作原理

The script (
lobehub/packages/openapi/scripts/compliance-test.sh
) clones the official openresponses/openresponses repo into
scripts/openresponses-compliance/
(gitignored) and runs its CLI test runner. First run clones; subsequent runs update from upstream.
脚本(
lobehub/packages/openapi/scripts/compliance-test.sh
)会将官方openresponses/openresponses仓库克隆到
scripts/openresponses-compliance/
目录(已加入gitignore)并运行其CLI测试运行器。首次运行会执行克隆操作,后续运行会从上游仓库拉取更新。

Debugging Failures

失败调试

  1. Run with
    -v
    to see full request/response payloads
  2. Common failure patterns:
    • "Failed to parse JSON": Auth failed, server returned HTML redirect
    • "Response has no output items": LLM execution not yet implemented
    • "Expected number, received null": Missing required field in response schema
    • "Invalid input": Zod validation on response schema — check field format
  1. 加上
    -v
    参数运行即可查看完整的请求/响应负载
  2. 常见失败场景:
    • "Failed to parse JSON":认证失败,服务端返回HTML重定向
    • "Response has no output items":LLM执行功能尚未实现
    • "Expected number, received null":响应schema中缺少必填字段
    • "Invalid input":响应schema未通过Zod校验,请检查字段格式

Key Files

关键文件

  • Types:
    lobehub/packages/openapi/src/types/responses.type.ts
  • Service:
    lobehub/packages/openapi/src/services/responses.service.ts
  • Controller:
    lobehub/packages/openapi/src/controllers/responses.controller.ts
  • Route:
    lobehub/packages/openapi/src/routes/responses.route.ts
  • Test script:
    lobehub/packages/openapi/scripts/compliance-test.sh
  • Cloud route:
    src/app/(backend)/api/v1/[[...route]]/route.ts
  • 类型定义
    lobehub/packages/openapi/src/types/responses.type.ts
  • 服务层
    lobehub/packages/openapi/src/services/responses.service.ts
  • 控制层
    lobehub/packages/openapi/src/controllers/responses.controller.ts
  • 路由定义
    lobehub/packages/openapi/src/routes/responses.route.ts
  • 测试脚本
    lobehub/packages/openapi/scripts/compliance-test.sh
  • 云端路由
    src/app/(backend)/api/v1/[[...route]]/route.ts