Add ability for AsHostedAgent() to use a deployed agent instead of running locally
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
_No response_
### Describe the solution you'd like
## Problem
`AsHostedAgent(...)` currently provides strong local-dev behavior by default, but there is no clean first-class mode for “use an already deployed hosted agent” without local run/provision behavior.
## Why this is a valid use case
- Teams could have pre-provisioned/shared Foundry agents.
- Local app development sometimes needs to target an existing deployed agent for parity.
## Important design requirement
For existing-agent mode, binding should be based on:
- **Agent name**
- **Existing Foundry project reference**
OR Raw endpoint URL.
The project reference should be the preferred source of endpoint/context, while agent identity is the agent name.
## Desired behavior
Allow `AsHostedAgent` to explicitly use an existing deployed agent in the referenced project, treating it as external and avoiding local run for that agent.
## Some API shape options
1. `AsHostedAgent(project).RunAsExisting(existingIdentifier)`
- **Pros:** aligns with existing `RunAs*` family.
- **Cons:** broad/ambiguous semantics for this scenario; RunAsExisting currently only exists for resources that are provisioned by default at dev time (and to run locally require something like RunAsEmulator or RunAsContaianer).
2. `AsHostedAgent(project).RunAsExistingHostedAgent(agentName)`
- **Pros:** explicit intent, clear semantics, best readability for this resource type.
- **Cons:** introduces a resource-specific API surface.
3. `AsHostedAgent(project, existingEndpoint: endpoint)`
- **Pros:** concise.
- **Cons:** not preferred; bypasses project context and encourages endpoint-centric configuration.
4. `AsHostedAgent(project, options => options.ExistingAgentName = "agent-name")`
- **Pros:** extensible for future knobs while staying project+name based.
- **Cons:** heavier syntax.
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.