d+
devoteam
Snowflake Partner
Consultant Self-Training

streamlit-coco

Consultant Self-Training.

Go through this deck alone, do the hands-on lab, and emerge ready to demo, build, and deliver streamlit-coco on a client engagement. Companion files: doc/training/*.md.

What is streamlit-coco?

One sentence: the elevator pitch
d+
devoteam
Snowflake Partner
A Python library that wraps Snowflake's Cortex Code Agent SDK ("CoCo") into production-ready Streamlit components — streaming agent UI, readable tool cards, and human-in-the-loop approval gates, in about 10 lines of code.
PyPI package
pip install streamlit-coco[sdk]
License
Apache-2.0, open source

The problem it solves

Why this library exists
d+
devoteam
Snowflake Partner
Teams building Streamlit apps on Snowflake want AI-assisted data exploration, code generation, and automated workflows. Wiring Cortex Code into a custom Streamlit app from scratch means building session management, streaming rendering, tool-card display, and safety gates yourself — weeks of plumbing with no reusable foundation.
Without streamlit-cocoWith streamlit-coco
Wire CoCo yourself across Streamlit rerunsSession + fragment polling that keeps streaming
Raw JSON tool dumpsMeaningful cards (Glob, Grep, Read, Write, SQL, AskUser…)
Hope the agent behavesrequire_approval_for + HITL UI
Chat-only demosStructured callbacks into your own widgets

How it fits the Snowflake ecosystem

Who built it, current maturity
d+
devoteam
Snowflake Partner
Position
Cortex Code today is consumed via CLI, Snowsight, Desktop, IDE extensions
streamlit-coco bridges the gap into custom Streamlit apps
Pure Python — no JS build step, works with SiS-style local Streamlit
Maturity & ownership
Level
N0 (alpha), targeting N1 — Snow Builders
Owner
Laurent Letourmy — Devoteam Snowflake Partner
Version
0.1.6 on PyPI

Current adoption & outcomes

Snapshot as of the roadmap's last success-check
d+
devoteam
Snowflake Partner
228
PyPI downloads last month
2
GitHub stars
0.1.6
Current alpha version
Honest state (be transparent with clients)
This is alpha software, 0 client engagements to date, and targets are still ahead of current usage (500+ downloads/month, 50+ stars, 3+ community examples). Position it accordingly: strong internal-tooling fit today, production readiness targeted at N1. Do not oversell maturity in a client conversation.

Typical engagement modes

Three ways teams plug this in
d+
devoteam
Snowflake Partner
INTERACTIVE
Analyst copilot
panel() + chat_input_bar() embedded in a dashboard; analysts ask questions, agent queries Snowflake with approval gates.
STRUCTURED
Self-updating widgets
Agent output routed into your own dataframes/charts via on_structured_output — no chat window needed.
HEADLESS
CI / pipeline step
query() in a script — no Streamlit import at all; embed CoCo in scheduled jobs or CI.

What you'll be able to do

Concrete outcomes after this deck + lab
d+
devoteam
Snowflake Partner
Explain it
What it does, when to use it vs. a bare CoCo CLI/Snowsight session
Run every demo
make chat, make backlog, make tableau-semantic, make headless, make structured, make cwd-upload
Build from scratch
A minimal app using panel() + chat_input_bar(), approval gates configured
Present a demo
Deliver the 12-minute scripted demo to a client or internal audience unassisted
Map to a project
Presales demo, delivery sprint (Assess→Build→Enable), or client workshop (W01)

How it works

"You own the page. CoCo owns the session."
d+
devoteam
Snowflake Partner
Flow (interactive mode)
check_environment() → verify SDK / CLI / Snowflake connection are ready, without starting an agent
render_start_gate() → shows status, only starts the session after you click "Start"
get_or_create_session() → creates/retrieves a CocoSession tied to a Streamlit session key
panel() + chat_input_bar() → renders the streaming transcript and your input, survives Streamlit reruns
copilot_rail() → wraps that panel as a right-rail Copilot (connection, queued jobs, compact transcript) — make tableau-semantic
Under the hood: the SDK spawns the CoCo CLI as a subprocess and streams NDJSON events
Same event model powers panel(), structured output, and headless query()

Key components

The public API surface you'll actually use
d+
devoteam
Snowflake Partner
CapabilityEntry points
Native panel + approvalspanel(), chat_input_bar(), render_approvals()
Tool cards & AskUser / plan UIdoc/features/tools-display/
Session & optionsCocoSession, CocoOptions, get_or_create_session
Headless eventsquery(), CocoSession.stream(), execute_plan()
File upload into cwd (0.1.5)upload_to_cwd(), cwd_uploader()
Copilot rail (0.1.6)copilot_rail(), transcript_view_pills()
Legacy CCv2chat()

Prerequisites

Full detail: doc/training/setup-guide.md
d+
devoteam
Snowflake Partner
Python 3.10+ and uv installed
A Snowflake account with Cortex Code access
A working ~/.snowflake/connections.toml (or CLI default connection)
The CoCo CLI (cortex) installed and on PATH
Git access to DevoteamSP/streamlit-coco-dev

Install & connect

Copy-paste ready
d+
devoteam
Snowflake Partner
git clone https://github.com/DevoteamSP/streamlit-coco-dev.git
cd streamlit-coco-dev
make install     # uv sync --extra dev
cortex --version # verify CoCo CLI
Then set up ~/.snowflake/connections.toml:
[connections.analytics]
account = "xy12345"
user = "you@company.com"
authenticator = "externalbrowser"

Verification checklist

You're ready for the lab when...
d+
devoteam
Snowflake Partner
import streamlit_coco as c; print(c.__version__) prints 0.1.6
cortex --version succeeds
check_environment(...).ready is True
make check passes with no failures
make chat opens a working app with a streamed response + tool card

First impression — panel()

Full exercise: hands-on-lab.md Exercise 1
d+
devoteam
Snowflake Partner
make chat   # runs examples/chat_app.py
Type: "What tables are available in SNOWFLAKE_SAMPLE_DATA.TPCH_SF1?"
Watch the transcript stream progressively, not all at once
Check: at least one tool card appears showing what the agent did

Approval gates

Full exercise: hands-on-lab.md Exercise 2
d+
devoteam
Snowflake Partner
Type: "Show me the top 5 customers by total order amount. Write the SQL and run it."
Approval banner fires — read the full SQL, click Approve once
Type: "Now create a summary table called TOP_CUSTOMERS." → click Deny with a reason
This is the core differentiator: every destructive tool (SQL, Write, Edit, Bash) pauses for an explicit human decision. No surprises.

Structured output

Full exercise: hands-on-lab.md Exercise 3
d+
devoteam
Snowflake Partner
make structured   # runs examples/structured_output.py

def render(data: dict, result: st_coco.CocoChatResult) -> None:
    st.dataframe(data.get("selected_features", []))

st_coco.panel(session=session, on_structured_output=render)
Type: "Give me a breakdown of orders by status" → renders as a chart, not raw JSON

Headless mode

Full exercise: hands-on-lab.md Exercise 4
d+
devoteam
Snowflake Partner
import asyncio
import streamlit_coco as coco

async def run():
    async for event in coco.query("Profile ANALYTICS.CUSTOMERS"):
        if event.type == "result":
            print(event.structured_output)

asyncio.run(run())   # or: make headless
No streamlit import anywhere — same query(), same event types, works in CI/scripts

Build from scratch

Full exercise: hands-on-lab.md Exercise 5 — the real test
d+
devoteam
Snowflake Partner
Using only the README quickstart (no copy-paste from examples/), write:
opts = st_coco.CocoOptions(
    connection="analytics", cwd=".",
    allowed_tools=["Read", "Glob", "Grep"],
    require_approval_for=["Edit", "Write", "Bash"],
)
env = st_coco.check_environment(connection=opts.connection)
if not st_coco.render_start_gate(opts, session_key="copilot", env=env):
    st.stop()
session = st_coco.get_or_create_session(opts, key="copilot")
st_coco.panel(session=session, warm_up=True, show_status=True)
st_coco.chat_input_bar(session, placeholder="Ask CoCo…")

Before you demo

Full script: doc/training/demo-script.md
d+
devoteam
Snowflake Partner
Snowflake account with Cortex Code access, connection configured
cortex --version succeeds; make check passes
A database with sample tables (e.g. SNOWFLAKE_SAMPLE_DATA.TPCH_SF1)
Terminal + browser side by side; dry-run once within 24h of the real demo

Opening hook (30s) + Act 1

~2 min
d+
devoteam
Snowflake Partner
"What if your Streamlit app had a built-in AI coding agent that can query Snowflake, read files, and write code — with guardrails? streamlit-coco gives you that in about 10 lines of code."
Show examples/chat_app.py (~20 lines) → run make chat → ask about TPCH_SF1 tables

Act 2 — Approval gates

~3 min
d+
devoteam
Snowflake Partner
"Show me the top 5 customers by total order amount. Write the SQL and run it." → Approve
"Now create a summary table called TOP_CUSTOMERS." → Deny with reason
Talking point: "Every destructive action — SQL, file writes, bash commands — requires explicit human approval. No surprises."

Act 3+4 — Output & headless

~2 min (headless optional if time is tight)
d+
devoteam
Snowflake Partner
make structured → "Give me a breakdown of orders by status" → renders as a chart
make headless → terminal streams events, no browser
Talking point: "Agent output flows into your widgets. CI pipelines, scheduled jobs — embed CoCo anywhere Python runs."

Closing & CTA

~2.5 min
d+
devoteam
Snowflake Partner
pip install streamlit-coco[sdk] — 5 minutes to first working app
Safety by default — approval gates on for all destructive tools
Flexible — interactive panel, structured output, or headless, same library
CTA: "Try it against your own Snowflake account this week — the README quickstart gets you to a working app in under 10 minutes."

Top mistakes new users make

Save yourself the debugging time
d+
devoteam
Snowflake Partner
Listing the same tool in both allowed_tools and require_approval_for — don't overlap them
Assuming unlisted tools auto-run — the default is require approval unless explicitly allowed
Expecting Streamlit Community Cloud or SiS support today — CoCo needs a subprocess + CLI on the same host
Skipping check_environment() and debugging a stuck session blind — always check readiness first
Positioning this as production-ready to a client — it's alpha (0.1.6), be upfront

FAQ

Answers you'll actually be asked in a demo
d+
devoteam
Snowflake Partner
Does it work with SiS?Not yet — pure Python, waiting on the CoCo API path; see roadmap.
What LLM does it use?Whatever Cortex Code uses under the hood — no config needed.
Can I customize approvals?Yes — allowed_tools / require_approval_for in CocoOptions.
Is it production-ready?Alpha (0.1.6) — fine for internal tools; production readiness targeted at N1.
Vs. the CoCo CLI directly?This library owns the Streamlit-specific plumbing (session, streaming, cards, approvals) — the CLI alone has none of that.

5 things to remember

Core principles
d+
devoteam
Snowflake Partner
01
"You own the page, CoCo owns the session" — panel()/chat_input_bar() is the preferred pattern
02
Safety by default: unlisted tools require approval; be deliberate about allowed_tools
03
Three modes, one library: interactive panel, structured output, headless query()
04
This is alpha (0.1.6) — be honest about maturity with clients, no client engagements yet
05
Golden-path checklists live in doc/features/ — run them before signing off a release demo

Where to go next

Companion files for hands-on practice
d+
devoteam
Snowflake Partner
Training pack (doc/training/)
setup-guide.md
hands-on-lab.md
demo-script.md
quiz.md
Repo docs
README.md (quickstart)
doc/deployment/local.md
doc/api.md · doc/roadmap.md
doc/marketing/demo.md (source of truth for the client demo)
d+
devoteam
Snowflake Partner

Take the quiz next.

Open doc/training/quiz.md — score 8/10 or higher and you're considered trained for this asset's N0→N1 gate item.
Questions? Laurent Letourmy — asset owner