I want to build a minimal CoCo app
For a Python developer building a Streamlit app · 10 min · a working Python environment
You end up with a single-page Streamlit app that embeds a CoCo panel and input bar, using the preferred integration pattern.
Before you start#
streamlit-coco[sdk]installed (see Enablement- A Snowflake connection configured and reachable —
check_environment().readyshould already beTrue; see Getting started. - No prior CoCo app is required; this is the starting point for every other
task page in this guide.
Steps#
- Create
streamlit_app.pyand construct aCocoOptionswith at least aconnection name:
import streamlit as st import streamlit_coco as st_coco st.set_page_config(page_title="Minimal CoCo app") options = st_coco.CocoOptions( connection="my_connection", cwd=".", ) - Call
check_environment()through the landing gate, and stop the scriptif it is not ready:
if not st_coco.render_start_gate(options): st.stop()render_start_gate()renders the landing screen itself (SDK/CLI/Snowflake status, a Start action) and returnsFalsewhile the environment or the user has not confirmed — your app must callst.stop()in that case,render_start_gate()does not stop the script for you. - Get or create the session for this page, and mount the panel and its
input bar:
session = st_coco.get_or_create_session(options) st_coco.panel(session) st_coco.chat_input_bar(session)get_or_create_session()stores the session inst.session_state["coco"]by default (override withkey=) and reuses it across reruns. - Run the app:
streamlit run streamlit_app.py - Type a prompt in the input bar at the bottom of the page and confirm the
transcript streams a response above it.
Result#
A browser tab showing the CoCo panel: a status header, an empty transcript, and the chat input bar. After a prompt, the transcript fills with the agent's streamed response and any tool cards it used. No file is written by this minimal app on its own — file output starts once you add uploads (I want to add file uploads) or the agent writes to cwd.
Variations#
- Use
copilot_rail()instead ofpanel()+chat_input_bar()to embed CoCoas a right-hand rail inside a larger, multipage app rather than a single-page chat — see the Backlog Desk and BI → Semantic examples in Example apps reference.
- Set
panel(session, output_mode="field")to render only the latestassistant output instead of the full transcript.
- Set
warm_up=Trueonrender_start_gate()(the default) to start thesession as soon as the gate passes, instead of waiting for the first prompt.