Repository navigation
CTX7-3522: Docs feedback score and required comment, with a feedback request in the server instructions #3617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
2da16ea
8be28e1
d77dc33
f26161f
fa3d031
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,9 @@ import { recordToolCallTelemetry } from "./auth-lifecycle-telemetry.js"; | |
| import { SUBMIT_DOCS_FEEDBACK_TOOL } from "./tool-names.js"; | ||
| import type { ClientContext, DocsFeedback } from "./types.js"; | ||
|
|
||
| /** Added to the server instructions with research preview on, so agents remember the feedback tool. */ | ||
| export const DOCS_FEEDBACK_INSTRUCTIONS = `After you answer a question with documentation from 'query-docs', call '${SUBMIT_DOCS_FEEDBACK_TOOL}' once for that library with a score from 0 to 5 and a short comment on the docs. The user turned on this research preview to collect this feedback.`; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in fa3d031. It uses |
||
|
|
||
| /** | ||
| * Experimental tools, registered only with research preview on | ||
| * (`--research-preview`, `CONTEXT7_RESEARCH_PREVIEW=1` or `?research_preview=1`). | ||
|
|
@@ -20,10 +23,10 @@ export function registerResearchPreviewTools( | |
| title: "Submit Documentation Feedback", | ||
| description: `Sends feedback on documentation that 'Query Documentation' returned, so Context7 can fix its docs. | ||
|
|
||
| Call it once after you used the documentation of a library: | ||
| - helpful: true when the docs answered the question. | ||
| - helpful: false when they did not, with the issue: 'missing' (the docs do not cover it), 'outdated' (they describe an old version), 'incorrect' (the code or facts are wrong), 'irrelevant' (the results were about something else) or 'other'. | ||
| Also call it when the user comments on the documentation, with author 'user' and their words in comment. | ||
| Call it once after you used the documentation of a library to answer a question: | ||
| - score: how well the docs answered it, from 0 (useless) to 5 (fully answered with correct, current code). | ||
| - issue: what was wrong, only when the score is below 5: 'missing' (the docs do not cover it), 'outdated' (they describe an old version), 'incorrect' (the code or facts are wrong), 'irrelevant' (the results were about something else) or 'other'. | ||
| - comment: what was missing or wrong, or what was good, in one or two sentences. When the user comments on the documentation, pass on their words. | ||
|
|
||
| Do not include sensitive or confidential information such as API keys, passwords, credentials, personal data, or proprietary code.`, | ||
| inputSchema: z.object({ | ||
|
|
@@ -33,21 +36,21 @@ Do not include sensitive or confidential information such as API keys, passwords | |
| "The Context7-compatible library ID the feedback is about, as passed to 'query-docs' (e.g., '/vercel/next.js')." | ||
| ), | ||
| query: z.string().optional().describe("The 'query-docs' query the feedback is about."), | ||
| helpful: z.boolean().describe("Whether the documentation answered the question."), | ||
| score: z | ||
| .number() | ||
| .int() | ||
| .min(0) | ||
| .max(5) | ||
| .describe("How well the docs answered the question, from 0 (useless) to 5 (fully)."), | ||
| issue: z | ||
| .enum(["missing", "outdated", "incorrect", "irrelevant", "other"]) | ||
| .optional() | ||
| .describe("What was wrong. Only when helpful is false."), | ||
| .describe("What was wrong. Only when the score is below 5."), | ||
| comment: z | ||
| .string() | ||
| .optional() | ||
| .describe( | ||
| "Short details: what was missing or wrong, or what the user said. Up to 1000 characters." | ||
| ), | ||
| author: z | ||
| .enum(["agent", "user"]) | ||
| .min(1) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not match the app contract. The app trims the text, requires at least 1 character after the trim, and rejects more than 1,000 characters. Here
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in fa3d031. The comment is |
||
| .describe( | ||
| "'agent' for your own judgment of the docs, 'user' when you pass on the user's feedback." | ||
| "What was missing, wrong or good, in one or two sentences. Up to 1000 characters." | ||
| ), | ||
| }), | ||
| annotations: { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,10 +34,9 @@ export type ContextRequest = { | |
| export type DocsFeedback = { | ||
| libraryId: string; | ||
| query?: string; | ||
| helpful: boolean; | ||
| score: number; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in fa3d031. The schema is the |
||
| issue?: "missing" | "outdated" | "incorrect" | "irrelevant" | "other"; | ||
| comment?: string; | ||
| author: "agent" | "user"; | ||
| comment: string; | ||
| }; | ||
|
|
||
| export type ContextResponse = { | ||
|
|
@@ -57,6 +56,8 @@ export interface ClientContext { | |
| mcpAuthMode?: "observe" | "required"; | ||
| transport?: "stdio" | "http"; | ||
| sessionId?: string; | ||
| /** Research preview is on; sent as `X-Context7-Research-Preview: 1` so the app counts preview use. */ | ||
| researchPreview?: boolean; | ||
| /** Mutable: set by the upstream API layer when the backend signals the | ||
| * client should be prompted to sign in. Read by the auth-prompt wrapper. */ | ||
| shouldPrompt?: boolean; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wrapper is not necessary.
ClientContextis already built in exactly two places: the HTTP context object (const context: ClientContext = {...}in the request handler) and the stdio fallback ingetClientContext.Suggestion: set
researchPreviewthere.research_previewquery parameter (isResearchPreviewValue).stdioSessionId.Then this wrapper, the 3 changed call sites, the changed
registerResearchPreviewToolssignature and the...(x ? { researchPreview: true } : {})spread all go away.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in fa3d031. The HTTP context reads
research_previewfrom the query withisResearchPreviewValue, and stdio uses a module-levelstdioResearchPreviewnext tostdioSessionId. The wrapper is gone, the call sites usegetClientContextagain, andregisterResearchPreviewToolshas its old signature.