Skip to content

Adding the GH Support - #179

Open
Swapnil Nagar (swapnil-nagar) wants to merge 2 commits into
mainfrom
swapnil/supportGHModel
Open

Adding the GH Support#179
Swapnil Nagar (swapnil-nagar) wants to merge 2 commits into
mainfrom
swapnil/supportGHModel

Conversation

@swapnil-nagar

Copy link
Copy Markdown

Purpose

  • Add GitHub Models as a built-in Microsoft Agent Framework inference provider using the existing OpenAI-compatible client.
  • Support explicit AZURE_FUNCTIONS_AGENTS_PROVIDER=github selection and dedicated-token auto-detection after all existing providers.
  • Resolve authentication from GITHUB_MODELS_TOKEN, falling back to GITHUB_TOKEN only when GitHub Models is explicitly selected.
  • Support GITHUB_MODELS_MODEL and GITHUB_MODELS_ENDPOINT, defaulting to openai/gpt-4.1-mini and https://models.github.ai/inference.
  • Add a minimal local-first sample under samples/github-models-chat with the built-in browser UI, JSON chat endpoint, and streaming endpoint.
  • Document the design and decisions in FRD 0008 and update shared provider guidance.

Does this introduce a breaking change?

```
[ ] Yes
[x] No
```

Existing explicit provider values and auto-detection precedence are preserved. Generic GITHUB_TOKEN does not participate in auto-detection, avoiding accidental selection in GitHub Actions and other GitHub-integrated environments.

Pull Request Type

```
[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[x] Documentation content changes
[ ] Other... Please describe:
```

How to Test

  • Get the code

```bash
git clone https://github.com/Azure/azure-functions-agents-runtime.git
cd azure-functions-agents-runtime
git checkout swapnil/supportGHModel
python -m pip install -U -e .[dev]
```

  • Run the validation gates

```bash
python -m ruff check src tests
python -m mypy src
python -m pytest --cache-clear --cov=./src/azure_functions_agents --cov-report=xml --cov-branch tests
```

  • Try the sample

```powershell
cd samples/github-models-chat/src
Copy-Item local.settings.template.json local.settings.json

Replace in local.settings.json, then:

func start
```

Open http://localhost:7071/agents/main/ or run the requests in samples/github-models-chat/test.http.

What to Check

  • Explicit provider=github accepts GITHUB_MODELS_TOKEN and the GITHUB_TOKEN fallback.
  • Auto-detection uses only GITHUB_MODELS_TOKEN and remains lower precedence than Azure OpenAI, Foundry, and OpenAI.
  • Requested model and environment fallback precedence match FRD 0008.
  • The endpoint override is passed unchanged to MAF's OpenAIChatClient.
  • The sample composes its built-in chat UI, chat API, and streaming API without contacting the provider at startup.
  • Credentials are never included in InferenceTarget or logs.

Other Information

  • No new package dependency or authoring/schema change is required.
  • Independent architecture and testing reviews approved the implementation.
  • Local validation completed: Ruff clean, strict mypy clean, and 1,077 tests passed with 53 deselected.
  • Design record: docs/frds/0008-github-models-provider.md.
    '@; gh pr create --base main --head swapnil/supportGHModel --title "feat: add GitHub Models provider and chat sample" --body $body

@swapnil-nagar
Swapnil Nagar (swapnil-nagar) requested a review from a team as a code owner August 26, 2026 21:52
@swapnil-nagar
Swapnil Nagar (swapnil-nagar) marked this pull request as draft August 26, 2026 21:53
@swapnil-nagar
Swapnil Nagar (swapnil-nagar) marked this pull request as ready for review August 26, 2026 22:07

- Add `github` as a valid `AZURE_FUNCTIONS_AGENTS_PROVIDER` value.
- Build GitHub Models clients through MAF's existing `OpenAIChatClient`.
- Authenticate with `GITHUB_MODELS_TOKEN`, falling back to `GITHUB_TOKEN` only when the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not just use GITHUB_TOKEN only? Why introduce a new variable?

provider is explicitly `github`.
- Auto-detect GitHub Models from non-blank `GITHUB_MODELS_TOKEN` after all existing provider
signals, preserving existing selection precedence.
- Resolve models as requested model, then `GITHUB_MODELS_MODEL`, then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

GITHUB_MODELS_MODEL is a mouthful, can we just do GITHUB_MODEL?
(Ideally I would not prefer adding any variables but given this is the norm so far, it would be cleaner to make it simple atleast).


- Add GitHub repository, GitHub App, OAuth, or GitHub API integration.
- Provision tokens, models, billing, rate limits, or GitHub organization policy.
- Auto-detect from generic `GITHUB_TOKEN`, which may exist for unrelated GitHub operations.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Given we anyways select Github last from our provider list, is this really that big a deal? I think it gives users a clean experience if we conform to predefined constants.

- bash: |
python -m pytest -m e2e tests/endtoend/test_github_models_agentic.py -v
displayName: 'Run GitHub Models live E2E test'
condition: and(succeeded(), ne(variables['GITHUB_MODELS_TOKEN'], ''))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we want this? It would require adding some GH token to the pipeline and that might need to be rotated every often (cc: hallvictoria )

`GITHUB_MODELS_ENDPOINT` override for testing and future-compatible gateways.
- Report `provider=github` and the resolved model through existing inference-target
observability metadata.
- Include a minimal local-first chat sample using the built-in browser and HTTP endpoints.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Given its a small basic sample, I'm wondering if we can just retrofit one of the existing samples to use GitHub instead? It can actually be a stronger story to sell if the global config uses foundry and one specific agent can resolve to Github to showcase we're LLM agnostic.

)

@classmethod
def _build_github(cls, model: str) -> Any:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NIT: Make sure its strongly typed and not returning Any

if requested:
return requested
runtime_model = runtime_env_value("AZURE_FUNCTIONS_AGENTS_MODEL")
if provider == "azure_openai":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since you're touching this, can you make the providers an Enum or a StrEnum to make it more strongly typed please?

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