Guard protocol generation against context truncation
This commit is contained in:
@@ -30,6 +30,7 @@ from src.meeting_lab.models.meeting_context import (
|
||||
from src.meeting_lab.progress import ProgressEvent, ProgressSink, ProgressStatus
|
||||
from src.meeting_lab.protocol.generate_direct_protocol import (
|
||||
DEFAULT_MODEL,
|
||||
DEFAULT_SAFE_INPUT_TOKEN_BUDGET,
|
||||
DirectProtocolResult,
|
||||
generate_direct_protocol,
|
||||
load_compact_transcript,
|
||||
@@ -54,6 +55,7 @@ class MvpMeetingConfig:
|
||||
threads: str | int = "auto"
|
||||
model: str = DEFAULT_MODEL
|
||||
ollama_endpoint: str = DEFAULT_ENDPOINT
|
||||
protocol_safe_input_token_budget: int = DEFAULT_SAFE_INPUT_TOKEN_BUDGET
|
||||
diarization: str = "off"
|
||||
diarization_runtime: str = "native"
|
||||
diarization_container_image: str | None = None
|
||||
@@ -127,6 +129,8 @@ def _validate_inputs(
|
||||
and not config.diarization_container_image
|
||||
):
|
||||
raise ValueError("A diarization container image is required.")
|
||||
if config.protocol_safe_input_token_budget <= 0:
|
||||
raise ValueError("Protocol safe input token budget must be positive.")
|
||||
|
||||
|
||||
def _emit(
|
||||
@@ -154,6 +158,11 @@ def _persist_protocol(run_dir: Path, result: DirectProtocolResult) -> Path:
|
||||
(protocol_dir / "exact_prompt.txt").write_text(result.exact_prompt, encoding="utf-8")
|
||||
_write_json(protocol_dir / "raw_response.json", result.raw_response)
|
||||
_write_json(protocol_dir / "runtime_metadata.json", result.runtime_metadata)
|
||||
transcript_input = getattr(result, "transcript_input", None)
|
||||
if transcript_input is not None:
|
||||
(protocol_dir / "transcript_input.txt").write_text(
|
||||
transcript_input, encoding="utf-8"
|
||||
)
|
||||
protocol_path = run_dir / "protocol.md"
|
||||
protocol_path.write_text(result.protocol_text, encoding="utf-8")
|
||||
return protocol_path
|
||||
@@ -354,6 +363,7 @@ def run_mvp_meeting(
|
||||
preserved_context,
|
||||
model=config.model,
|
||||
endpoint=config.ollama_endpoint,
|
||||
safe_input_token_budget=config.protocol_safe_input_token_budget,
|
||||
)
|
||||
stage_runtimes["protocol"] = round(time.perf_counter() - stage_started, 3)
|
||||
protocol_path = _persist_protocol(run_dir, result)
|
||||
|
||||
Reference in New Issue
Block a user