Skip to content

AdditionalContext in OnUserPromptSubmitted hook output is silently ignored [.NET SDK] #775

@nathan815

Description

@nathan815

Summary

When using the OnUserPromptSubmitted hook and returning a UserPromptSubmittedHookOutput with AdditionalContext set, the context is not injected into the conversation for the model. The hook fires correctly (confirmed via logging), but the model does not receive the additional context.

Using ModifiedPrompt on the same hook output works as expected — the model sees the modified prompt. This suggests the issue is specifically with AdditionalContext handling in the CLI runtime.

Reproduction

Minimal reproduction here: https://gist.github.com/nathan815/264d78ff877435932bd42f28b97f07e2

  1. Configure a BYOK provider (Azure OpenAI):
var session = await client.CreateSessionAsync(new SessionConfig
{
    Model = "gpt-5.2-chat",
    Provider = new ProviderConfig
    {
        Type = "azure",
        BaseUrl = "https://<endpoint>.openai.azure.com/openai/deployments/gpt-5.2-chat",
        ApiKey = "<key>",
        Azure = new AzureOptions { ApiVersion = "2025-03-01-preview" },
    },
    Streaming = true,
    Hooks = new SessionHooks
    {
        OnUserPromptSubmitted = (input, invocation) =>
        {
            Console.WriteLine($"Hook fired: {invocation.SessionId}");
            return Task.FromResult<UserPromptSubmittedHookOutput?>(
                new UserPromptSubmittedHookOutput
                {
                    AdditionalContext = "The user is currently viewing resource abc123 in region eastus2",
                }
            );
        },
    },
});

await session.SendAsync(new MessageOptions { Prompt = "What am I looking at?" });
  1. The hook fires (confirmed via console output).
  2. The model responds as if it has no additional context.

Expected behavior

The AdditionalContext string should be injected into the conversation so the model can see it, as documented:

AdditionalContext - Additional context to inject into the conversation for the language model.

Environment

  • SDK: GitHub.Copilot.SDK 0.1.32 (.NET)
  • Provider: Azure OpenAI (BYOK)
  • Model: gpt-5.2-chat
  • OS: Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions