Skip to content

Commit ac71e54

Browse files
jodeklotzmsclaude
andcommitted
fix: fall back to session_id for multi-turn when conversation_id is missing
The ResponseHandler context only populates conversation_id when the request includes an explicit "conversation" field. Most callers (invoke scripts, Playground) only send session_id. Without this fallback, conversation_id is always None and the adapter creates a fresh Copilot SDK session on every request, breaking multi-turn. Also fixes Windows --no-logs in integration test deploy script. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e5a5f2e commit ac71e54

File tree

2 files changed

+42
-10
lines changed

2 files changed

+42
-10
lines changed

sdk/agentserver/azure-ai-agentserver-githubcopilot/azure/ai/agentserver/githubcopilot/_copilot_adapter.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,24 @@ async def handle_create(request, context, cancellation_signal):
362362
async def _handle_create(self, request, context, cancellation_signal):
363363
"""Handle POST /responses — bridge Copilot SDK events to RAPI stream."""
364364
input_text = _extract_input_with_attachments(request)
365+
366+
# Resolve conversation identity for multi-turn session reuse.
367+
# Prefer conversation_id from the context (set when the request includes
368+
# a "conversation" field). Fall back to session_id from the parsed
369+
# request so that callers who only pass session_id still get multi-turn.
365370
conversation_id = getattr(context, "conversation_id", None)
371+
if not conversation_id:
372+
# Try session_id from the parsed request object
373+
parsed = getattr(context, "request", None) or getattr(context, "parsed", None)
374+
if parsed is not None:
375+
conversation_id = getattr(parsed, "session_id", None)
376+
# Last resort: check the raw request
377+
if not conversation_id:
378+
if isinstance(request, dict):
379+
conversation_id = request.get("session_id")
380+
else:
381+
conversation_id = getattr(request, "session_id", None)
382+
366383
response_id = getattr(context, "response_id", None) or "unknown"
367384

368385
logger.info(f"Request: input={input_text[:100]!r} conversation_id={conversation_id}")

sdk/agentserver/azure-ai-agentserver-githubcopilot/tests/integration/deploy.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,38 @@ def build_image(staging_dir: Path, acr: str, name: str, tag: str) -> str:
6969
full_image = f"{acr}.azurecr.io/{name}:{tag}"
7070
print(f"Building {full_image} via ACR Tasks...")
7171

72+
is_win = sys.platform == "win32"
73+
7274
cmd = ["az", "acr", "build",
7375
"--registry", acr,
7476
"--image", f"{name}:{tag}",
7577
"--platform", "linux/amd64",
7678
"--file", str(staging_dir / "Dockerfile"),
7779
str(staging_dir)]
7880

79-
is_win = sys.platform == "win32"
80-
env = {**os.environ, "PYTHONIOENCODING": "utf-8", "PYTHONUTF8": "1"} if is_win else None
81-
proc = subprocess.Popen(
82-
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
83-
encoding="utf-8", errors="replace", shell=is_win, env=env,
84-
)
85-
for line in proc.stdout:
86-
sys.stdout.write(line)
87-
sys.stdout.flush()
88-
returncode = proc.wait()
81+
if is_win:
82+
# Skip log streaming on Windows to avoid colorama + cp1252 encoding crash.
83+
cmd.insert(3, "--no-logs")
84+
print(" (Windows: using --no-logs to avoid encoding issues)")
85+
env = {**os.environ, "PYTHONIOENCODING": "utf-8", "PYTHONUTF8": "1"}
86+
result = subprocess.run(
87+
cmd, capture_output=True, encoding="utf-8", errors="replace",
88+
shell=True, env=env,
89+
)
90+
if result.stdout:
91+
sys.stdout.write(result.stdout)
92+
if result.stderr:
93+
sys.stderr.write(result.stderr)
94+
returncode = result.returncode
95+
else:
96+
proc = subprocess.Popen(
97+
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
98+
encoding="utf-8", errors="replace",
99+
)
100+
for line in proc.stdout:
101+
sys.stdout.write(line)
102+
sys.stdout.flush()
103+
returncode = proc.wait()
89104

90105
if returncode != 0:
91106
print("\nWarning: az acr build returned non-zero exit code.", file=sys.stderr)

0 commit comments

Comments
 (0)