Skip to content

fix(proxy): register pi in AGENT_PREFIX_RE - #1195

Open
san-tian wants to merge 1 commit into
TencentCloud:feat/server_teamfrom
san-tian:fix/pi-agent-prefix-re
Open

fix(proxy): register pi in AGENT_PREFIX_RE#1195
san-tian wants to merge 1 commit into
TencentCloud:feat/server_teamfrom
san-tian:fix/pi-agent-prefix-re

Conversation

@san-tian

Copy link
Copy Markdown

Summary

Follow-up to #1126 (first-class Pi adapter). That PR added the pi agent adapter but left AGENT_PREFIX_RE without pi, so /pi/{spaceId}/v1/... requests are not prefix-stripped and cost-guard / analyse markers on /pi paths are not recognized (whitelist matching misses).

This PR is the minimal change:

  • Add pi to the AGENT_PREFIX_RE alternation (one line)
  • Add vitest tests covering:
    • /pi/v1/messages and /pi/{spaceId}/v1/... normalization
    • cost-guard / analyse markers on /pi paths
    • whitelist endpoint matching for /pi paths
    • regression for existing agent prefixes (claude-code, codebuddy)

Test

cd MemoryProxy && npx vitest run src/routes/__tests__/whitelist.test.ts
# 13 passed

Supersedes #1062.

The first-class pi adapter (TencentCloud#1126) handles /pi/{spaceId}/v1/... requests,
but AGENT_PREFIX_RE still lacks "pi", so cost-guard / analyse markers on
/pi paths are not recognized and whitelist matching misses. Add "pi" to
the agent alternation and cover normalization + marker + whitelist-matching
paths with vitest tests.

Signed-off-by: san-tian <admin@macaron.xin>
@Maxwell-Code07

Copy link
Copy Markdown
Collaborator

Thank you so much for your attention and contribution! We will arrange an internal review for this PR shortly, and all feedback will be shared right here in the discussion.

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.

2 participants