Skip to content

--new-session doesn't create a new session when an existing conversation ID is present #7866

@therealjohn

Description

@therealjohn

Goal

azd ai agent invoke --new-session results in a new session ID from the backend.

Context

The backend derives sessions from a conversation ID, so when --new-session is used and an existing conversation ID is present in the .foundry-agent.json, the same session ID is returned by the server.

This is unexpected because we have --new-session and --new-conversation as separate flags.

To workaround this and always get a new session, you have to pass both --new-session and --new-conversation.

I think we can make these mutually exclusive. new session always does a new conversation too.

Current Behavior

when --new-session is used and an existing conversation ID is present in the .foundry-agent.json, the same session ID is returned by the server.

Desired Behavior

when --new-session is used it also starts a new conversation so that a new session ID is received.

Implementation Notes (optional but powerful)

  • --new-session automatically includes the behavior of --new-conversation, like if I do --new-session --new-conversation today.
  • --new-session --new-conversation is still valid, its just not necessary anymore since --new-session will include it.
  • --new-conversation is valid alone, and continues to use the same session.

Acceptance Criteria

  • Unit tests added or updated
  • Existing test suite passes
  • Lint or format passes

How to Test

  1. azd ai agent init -m "https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/agent-framework/echo-agent/agent.yaml"
  2. azd up
  3. azd ai agent invoke "hello"
  4. azd ai agent invoke "hi" --new-session

Verify the session id between 3 and 4 are different.

Metadata

Metadata

Labels

ext-agentsazure.ai.agents extension

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions