Skip to content

[Feat/#69] 빌릴게 재고 도구를 백엔드 실데이터로 연결 - #70

Merged
overhyeon merged 2 commits into
mainfrom
feat/#69-real-item-stock
Nov 17, 2026
Merged

overhyeon merged 2 commits into
mainfrom
feat/#69-real-item-stock

Conversation

@overhyeon

Copy link
Copy Markdown
Contributor

#️⃣연관된 이슈

#69

📝작업 내용

빌릴게 재고 도구가 가짜 응답 대신 백엔드 실데이터를 읽게 했습니다.
백엔드가 중계할 때 넘겨주는 학생 JWT(X-User-Token, billilge/stream-server#310)로 기존 학생 API GET /v1/app/billilge/items를 조회만 합니다.

  • app.py: /chat이 X-User-Token을 받아 그 요청 동안만 도구에 넘깁니다
  • tools.py: _fetch_items()가 BACKEND_BASE_URL로 백엔드를 부릅니다
    • 토큰은 모델이 채우는 인자가 아니라 ContextVar(요청마다 따로 보관되는 변수)로 넘깁니다. 모델은 토큰을 볼 수 없습니다
    • BACKEND_BASE_URL이 비어 있으면 기존 가짜 응답을 씁니다(로컬 개발·평가)
    • ENV=prod인데 비어 있으면 서버가 뜨지 않습니다. 가짜 재고를 진짜처럼 보여주는 사고를 막습니다
    • 토큰은 로그에 남기지 않습니다
  • 문서: AGENTS.md 계약에 X-User-Token, .env.example·docs/guides/deploy.md에 BACKEND_BASE_URL

로컬 확인 (가짜 백엔드로 확인):

경우 결과
올바른 토큰 "마스크는 69개 남아 있어요" (백엔드 값 그대로)
틀린 토큰 / 토큰 없음 지어내지 않고 "확인할 수 없어요"
백엔드 주소 없음 기존 가짜 응답
prod인데 주소 없음 서버가 뜨지 않음

서버 로그에 토큰이 찍힌 횟수 0

💬리뷰 요구사항(선택)

머지 전에 Coolify(senv)에 BACKEND_BASE_URL을 먼저 넣어야 합니다. 값은 http://<백엔드 컨테이너 이름>:8080입니다. 빠지면 컨테이너가 뜨지 않아 챗봇이 멈춥니다.
실제 백엔드와 붙인 확인은 아직입니다. stream-server#310과 이 PR이 둘 다 배포된 뒤 개발 사이트에서 재고 질문으로 확인합니다.

@coderabbitai

coderabbitai Bot commented Nov 8, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 67a60e70-d066-49c6-acba-f6c0a12d87fb
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@seungbye seungbye left a comment

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.

코드는 좋아요. 승인할게요 👍

  • 토큰을 함수 인자가 아니라 ContextVar로 넘겨서 모델이 토큰을 아예 못 보는 구조가 좋아요
  • ENV=prod인데 BACKEND_BASE_URL이 없으면 서버가 뜨지 않게 막은 것도 좋아요. 가짜 재고가 진짜처럼 나가는 것보다 낫다고 봐요

참고 (머지를 막을 정도는 아님)

  • _fetch_items가 동기 httpx.get이고 llm._run_tool도 async 함수 안에서 동기로 불려요. 백엔드가 느리면 최대 5초 동안 이벤트 루프가 멈춰서 그 사이 다른 학생 답변 스트림도 같이 멈춰요. 지금 동시 접속 규모에서는 괜찮지만, 도구가 늘어나면(#80) asyncio.to_thread로 빼는 걸 고려해 봐요

머지 시점

  • stream-server#310이 아직 OPEN이에요. 이 PR만 먼저 main에 들어가면 바로 배포되고, 백엔드가 X-User-Token을 안 넘기니 재고 질문이 전부 "확인할 수 없어요"로 바뀌어요(지금은 가짜 재고로라도 답함)
  • 그래서 머지는 #310 머지·배포 + Coolify에 BACKEND_BASE_URL 넣은 뒤로 미뤄 둘게요
  • 참고로 #70 → #73 순서로 합쳐 봤는데 충돌은 없었어요

@overhyeon
overhyeon merged commit 7ad972c into main Nov 17, 2026
1 check passed
@overhyeon
overhyeon deleted the feat/#69-real-item-stock branch November 17, 2026 11:46
@overhyeon
overhyeon restored the feat/#69-real-item-stock branch November 17, 2026 11:46
@overhyeon
overhyeon deleted the feat/#69-real-item-stock branch November 17, 2026 11:47
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