Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ private async IAsyncEnumerable<string> ProcessAsync(
[EnumeratorCancellation] CancellationToken cancellationToken)
{
var userMessage = await context.GetInputTextAsync(cancellationToken: cancellationToken) ?? "";
var sessionId = request.AgentSessionId ?? "default";
// Hosted sessions may omit agent_session_id from the body; the platform
// supplies the session ID through FOUNDRY_AGENT_SESSION_ID instead.
var sessionId = FirstNonEmpty(
request.AgentSessionId,
Environment.GetEnvironmentVariable("FOUNDRY_AGENT_SESSION_ID"),
"default");

var options = new CreateResponseOptions { Instructions = SystemPrompt };
options.Tools.Add(s_saveNoteTool);
Expand Down Expand Up @@ -142,6 +147,9 @@ private async IAsyncEnumerable<string> ProcessAsync(
yield return $"(Tool-call loop exceeded {MaxToolRounds} rounds without producing a final response.)";
}

private static string FirstNonEmpty(params string?[] values) =>
values.First(value => !string.IsNullOrWhiteSpace(value))!;

private static string ExecuteToolCall(string functionName, BinaryData arguments, string sessionId)
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,13 @@ async def handle_create(
yield stream.emit_in_progress()

user_input = await context.get_input_text() or ""
session_id = request.get("agent_session_id") or "default"
# Hosted sessions may omit agent_session_id from the body; the platform
# supplies the session ID through FOUNDRY_AGENT_SESSION_ID instead.
session_id = (
request.get("agent_session_id")
or os.environ.get("FOUNDRY_AGENT_SESSION_ID")
or "default"
)

# Emit output item structure before streaming content
message_item = stream.add_output_item_message()
Expand Down
Loading