Skip to content

feat(ai-foundry): add TypeSpec for Foundry Routines#42779

Open
lindazqli wants to merge 2 commits into
Azure:feature/foundry-releasefrom
lindazqli:foundry-routines-typespec
Open

feat(ai-foundry): add TypeSpec for Foundry Routines#42779
lindazqli wants to merge 2 commits into
Azure:feature/foundry-releasefrom
lindazqli:foundry-routines-typespec

Conversation

@lindazqli

Copy link
Copy Markdown
Contributor

Summary

Adds TypeSpec models and routes for the Foundry Routines feature, based on the C# service contracts in Vienna.

New files

  • src/routines/models.tsp — all Routines domain models
  • src/routines/routes.tsp — 7 REST operations

Modified files

  • src/common/models.tsp — adds routines_v1_preview: "Routines=V1Preview" to FoundryFeaturesOptInKeys
  • main.tsp — imports src/routines/routes.tsp
  • openapi3/ — regenerated OpenAPI output

Routes

Method Path Description
PUT /routines/{routineName} Create or update a routine
GET /routines/{routineName} Get a routine
GET /routines List all routines
DELETE /routines/{routineName} Delete a routine
POST /routines/{routineName}:dispatch Synchronous dispatch
POST /routines/{routineName}:dispatchAsync Asynchronous dispatch
GET /routines/{routineName}/runs List routine run history

Key model design

  • RoutineTrigger discriminated on type: "schedule", "timer", "github_issue"
  • RoutineAction discriminated on type: "invoke_agent_responses_api", "invoke_agent_invocations_api"
  • Routine.triggers is Record<RoutineTrigger> (named dict, matching C# Dictionary<string, RoutineTrigger>)
  • RoutineDispatchPayload discriminated on type matching RoutineActionType
  • All routes require Foundry-Features: Routines=V1Preview header

@github-actions

github-actions Bot commented Apr 30, 2026

Copy link
Copy Markdown

Next Steps to Merge

⌛ Please wait. Next steps to merge this PR are being evaluated by automation. ⌛

Comment generated by summarize-checks workflow run.

@lindazqli

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

@lindazqli lindazqli marked this pull request as ready for review April 30, 2026 04:42
- Add src/routines/models.tsp with RoutineTrigger (schedule/timer/github_issue),
  RoutineAction (invoke_agent_responses_api / invoke_agent_invocations_api),
  RoutineDispatchPayload, RoutineRunDto, and RoutineRunsResponse models
- Add src/routines/routes.tsp with createOrUpdate, get, list, delete,
  dispatch, dispatchAsync, and listRuns operations
- Add routines_v1_preview feature flag to FoundryFeaturesOptInKeys
- Wire up main.tsp import
- Regenerate openapi3 output
@lindazqli lindazqli force-pushed the foundry-routines-typespec branch from 8275815 to 8570a43 Compare April 30, 2026 04:54
@github-actions github-actions Bot added data-plane TypeSpec Authored with TypeSpec labels Apr 30, 2026
@github-actions

github-actions Bot commented Apr 30, 2026

Copy link
Copy Markdown

API Change Check

APIView identified API level changes in this PR and created the following API reviews

Language API Review for Package
TypeSpec Azure.AI.Projects
Python azure-ai-projects
JavaScript @azure/ai-projects

Comment generated by After APIView workflow run.

string,

@doc("Cron-based recurring schedule trigger.")
Schedule: "schedule",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
Schedule: "schedule",
schedule: "schedule",

Schedule: "schedule",

@doc("One-shot timer trigger.")
Timer: "timer",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
Timer: "timer",
timer: "timer",

Timer: "timer",

@doc("GitHub issue event trigger.")
GitHubIssue: "github_issue",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
GitHubIssue: "github_issue",
github_issue: "github_issue",

type: RoutineTriggerType.Timer;

@doc("One-shot fire time in ISO 8601 format. Example: `\"2030-01-02T03:04:05Z\"`.")
at?: string;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably need a more expressive name.

string,

@doc("Invoke a published agent via the workspace responses API.")
InvokeAgentResponsesApi: "invoke_agent_responses_api",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the feedback in the conceptual spec:

Suggested change
InvokeAgentResponsesApi: "invoke_agent_responses_api",
agent_response: "agent_response",


#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "We need explicit definition for header support"
@doc("Get a routine by name.")
get is Azure.Core.Foundations.ResourceOperation<

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "We need explicit definition for header support"
@doc("List all routines.")
@Rest.listsResource(Routine)
list is Azure.Core.Foundations.ResourceList<

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar as above: use the paged operation archetype with the types defined in servicepatterns.tsp, e.g:

@list
listRoutines is FoundryDataPlanePreviewOperation<
 FoundryFeaturesOptInKeys.routines_v1_preview,
  {
    ...CommonPageQueryParameters;
  },
  AgentsPagedResult<Routine>
>;

@doc("List execution history for a routine.")
@route("routines/{routine_name}/runs")
@get
listRuns is FoundryDataPlaneOperation<

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as the other list operation


#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "We need explicit definition for header support"
@doc("Asynchronously dispatch a routine. Returns immediately after enqueueing the action.")
@route("routines/{routine_name}:dispatchAsync")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use snake_case for the action


...RoutinesPreviewHeader;

@Http.bodyRoot

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since DispatchRoutineRequest does not have non-body fields (path, query, etc)... use @Body here

…conversation field

- Expand TimerRoutineTrigger.at @doc to cover ISO-8601, local+tz, and
  duration formats (e.g. '30m', '2h'); note reminder tool writes '{minutes}m'
- Rename conversation_id -> conversation in InvokeAgentResponsesApiRoutineAction
  to match actual wire format

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data-plane TypeSpec Authored with TypeSpec

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants