Repository navigation
feat: Refactor agent request context handling and improve agent defin… #125
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
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { z } from 'zod' | ||
|
|
||
| export const chatTransportRequestSchema = z | ||
| .object({ | ||
| id: z.string().optional(), | ||
| messages: z.array(z.unknown()).default([]), | ||
| trigger: z.string().optional(), | ||
| messageId: z.string().optional(), | ||
| requestMetadata: z.unknown().optional(), | ||
| requestContext: z.record(z.string(), z.unknown()).optional(), | ||
| memory: z | ||
| .object({ | ||
| thread: z.string().optional(), | ||
| resource: z.string().optional(), | ||
| }) | ||
| .partial() | ||
| .optional(), | ||
| data: z | ||
| .object({ | ||
| agentId: z.string().min(1).optional(), | ||
| input: z.string().optional(), | ||
| }) | ||
| .loose() | ||
| .optional(), | ||
| }) | ||
| .loose() | ||
|
|
||
| export type ChatTransportRequest = z.infer<typeof chatTransportRequestSchema> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,3 +1,41 @@ | ||||||
| # 2026-03-17 codingAgents normalization | ||||||
|
|
||||||
| - Restored `codingAgents.ts` after a bad intermediate state: | ||||||
| - local tool objects are back in place by concrete tool name | ||||||
| - no explicit `new Agent<...>` tool generic remains in that file | ||||||
| - targeted validation for `codingAgents.ts` is clean | ||||||
| - Rechecked `src/mastra/agents` after the fix: | ||||||
| - ✅ **No errors found** | ||||||
|
|
||||||
| # 2026-03-17 full nested-agent source fix for networks/a2a | ||||||
|
|
||||||
| - Completed the remaining nested-agent typing cleanup the user requested across `src/mastra/networks` and `src/mastra/a2a`. | ||||||
| - Removed the bad `ToolsInput` additions from the touched agent implementations. | ||||||
| - Reworked the remaining child agents so parent registration compiles by source design rather than parent-side casting/adaptering. | ||||||
|
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. issue (typo): The term "adaptering" here is unconventional; "adapting" would be clearer. Consider updating the phrase to "casting/adapting" or "casting/adapter-based registration" to align with standard terminology.
Suggested change
|
||||||
| - Fixed adjacent diagnostics encountered during the pass: | ||||||
| - invalid `unknown` template interpolation in `knowledgeIndexingAgent.ts` | ||||||
| - `codingAgents.ts` unused import + `projectRoot` stringification issue | ||||||
| - unused `requestContext` / `userId` in A2A coordinators | ||||||
| - `codingTeamNetwork.ts` async/no-await quality-gate bug | ||||||
| - Validation: | ||||||
| - ✅ edited agent files clean | ||||||
| - ✅ `src/mastra/a2a` clean | ||||||
| - ✅ `src/mastra/networks` clean | ||||||
|
|
||||||
| # 2026-03-17 nested-agent typing fix without adapter | ||||||
|
|
||||||
| - Fixed the reported `seoAgent.ts` nested child-agent assignment failures for: | ||||||
| - `researchAgent` | ||||||
| - `contentStrategistAgent` | ||||||
| - `evaluationAgent` | ||||||
| - Kept the solution at the source rather than adding a parent-side adapter: | ||||||
| - shared request-context keys now come from `src/mastra/agents/request-context.ts` | ||||||
| - touched child agents parse specialized runtime context internally | ||||||
| - touched child agents now expose `unknown` as their public `Agent` request-context generic so direct parent registration compiles cleanly | ||||||
| - Validation: | ||||||
| - ✅ targeted `get_errors` on `request-context.ts`, `researchAgent.ts`, `contentStrategistAgent.ts`, `evaluationAgent.ts`, and `seoAgent.ts` returned clean | ||||||
| - ⚠️ folder-wide `get_errors` on `src/mastra/agents` still shows unrelated pre-existing diagnostics in `knowledgeIndexingAgent.ts` | ||||||
|
|
||||||
| # 2026-03-16 use-mastra-query full client-js hook expansion | ||||||
|
|
||||||
| - Completed the requested `@mastra/client-js` parity pass in `lib/hooks/use-mastra-query.ts` without replacing the file’s existing hook-factory pattern. | ||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The schema for
messagesis currently usingz.array(z.unknown()), which provides no type safety for the message objects. To improve validation and align with the goal of better type safety, consider defining a more specific schema for the message objects. Even a minimal schema would be an improvement.For example, you could define a schema that validates the basic structure of a message: