feat: 숲봇 답변에 warm 인스턴스 메모리 기반 문맥 추가 - #5
Merged
Merged
Conversation
Soopbot answered each question in isolation, so a follow-up like "왜 그렇지?" could not reach the answer it referred to. The template deliberately ships without a database, so durable history is out of scope. Reuse the pattern MemoryRequestGuard already established: keep the newest turns in the warm serverless instance and render them into the prompt. Turns never touch disk, expire 30 minutes after their last use, are capped so a long-lived instance cannot grow without bound, and are never shared between instances. Failed answers and the bare-trigger introduction are not remembered. SOOPBOT_MAX_HISTORY_TURNS (default 4) tunes it, and 0 restores the previous one-question-at-a-time behaviour. The deploy link still needs only the two secrets. README and docs/customize.md now disclose the in-memory retention instead of claiming the bot keeps no context. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The lazy provider wrapper accepted only persona and question, so once the reply service started passing context every generated answer failed the keyword check and fell back to the provider-failure message. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
문제
숲봇은 질문 하나하나를 독립적으로 답해서,
숲봇아 왜 그렇지?같은 후속 질문이 자기 직전 답변에 닿지 못했습니다.이 템플릿은 의도적으로 데이터베이스 없이 배포되므로(원클릭 Deploy에 필요한 env는
OPENAI_API_KEY,SOOPBOT_TOKEN둘뿐), 내구성 있는 대화 기록은 범위 밖입니다.접근
MemoryRequestGuard가 이미 쓰고 있는 패턴을 그대로 따릅니다 — warm 서버리스 인스턴스 메모리에 최근 턴을 두고 프롬프트에 넣습니다. 인프라 추가가 없어 원클릭 배포가 그대로 유지됩니다.MAX_TURNS = 20으로 상한 — 오래 사는 인스턴스에서도 무한 증가 없음SOOPBOT_MAX_HISTORY_TURNS(기본4, 범위 0~10)로 조절하고,0이면 기존 동작으로 완전히 돌아갑니다.프롬프트 변화
문서 (공개 템플릿이라 중요)
README가
이전 대화 문맥 없이,무상태 방식이라고 명시하고 있었고, 데이터 처리 항목이 "저장하지 않습니다"로만 되어 있었습니다. 이제 메모리 보관 사실을 명시합니다 — 어디에 얼마나 남고 언제 사라지는지.docs/customize.md에 환경변수와 비용 영향(턴 수를 늘리면 요청당 토큰 증가)을 추가했고,.env.example에도 반영했습니다.기존 문서 계약 테스트는 그대로 통과하며, 메모리 보관 고지를 강제하는 계약 테스트를 새로 추가했습니다.
테스트
TDD로 작성했고 77개 전부 통과합니다 (
check_test_discovery,check_public_tree포함).실패를 먼저 확인한 것:
두 번째 커밋에 대해
리베이스로 상류의
_LazyOpenAIProvider(#1에서 추가)가 들어오면서 실제 프로덕션 경로가 깨졌습니다 — 래퍼가context키워드를 안 받아 모든 생성 답변이 프로바이더 실패 메시지로 떨어졌습니다.test_generated_replies_reuse_one_lazily_constructed_provider가 이걸 잡아냈고, 두 번째 커밋에서 래퍼가context를 전달하도록 고쳤습니다.