diff --git a/computer-use-demo/computer_use_demo/loop.py b/computer-use-demo/computer_use_demo/loop.py index de91c430..2ca05da6 100644 --- a/computer-use-demo/computer_use_demo/loop.py +++ b/computer-use-demo/computer_use_demo/loop.py @@ -101,7 +101,7 @@ async def sampling_loop( while True: enable_prompt_caching = False betas = [COMPUTER_USE_BETA_FLAG] - image_truncation_threshold = 10 + image_truncation_threshold = only_n_most_recent_images or 0 if provider == APIProvider.ANTHROPIC: client = Anthropic(api_key=api_key, max_retries=4) enable_prompt_caching = True @@ -114,7 +114,8 @@ async def sampling_loop( betas.append(PROMPT_CACHING_BETA_FLAG) _inject_prompt_caching(messages) # Is it ever worth it to bust the cache with prompt caching? - image_truncation_threshold = 50 + if image_truncation_threshold: + image_truncation_threshold = 0 system["cache_control"] = {"type": "ephemeral"} if only_n_most_recent_images: diff --git a/computer-use-demo/computer_use_demo/streamlit.py b/computer-use-demo/computer_use_demo/streamlit.py index 6700a97c..40b24b40 100644 --- a/computer-use-demo/computer_use_demo/streamlit.py +++ b/computer-use-demo/computer_use_demo/streamlit.py @@ -85,7 +85,7 @@ def setup_state(): if "tools" not in st.session_state: st.session_state.tools = {} if "only_n_most_recent_images" not in st.session_state: - st.session_state.only_n_most_recent_images = 10 + st.session_state.only_n_most_recent_images = 3 if "custom_system_prompt" not in st.session_state: st.session_state.custom_system_prompt = load_from_storage("system_prompt") or "" if "hide_images" not in st.session_state: