A quick disclaimer: Steve is a personal portfolio project. It has never been used with real patients, is not clinically validated, and is not HIPAA compliant. Every patient, provider, and scenario in the demo is fictional. Much of its backend functionality, including schedules, chart lookups, and appointment availability, is simulated. I'll explain why that distinction matters throughout this article.
I work in healthcare patient services, so I have a practical understanding of the kinds of requests that come through a primary care front office every day.
A lot of the work involves a relatively small set of recurring requests:
These conversations may be repetitive, but they are not necessarily simple.
Who is calling matters. Whether the caller is authorized to receive patient information matters. Whether the office is open, whether the patient is a minor, and whether a medication is a controlled substance can all change how a request should be handled.
That combination of repetitive interactions and important workflow rules made me interested in a particular question:
In an AI application, the interesting design question isn't just what the LLM can do. It's what the LLM should be allowed to decide.
I spent approximately 6½ months building Steve, a text-based chatbot designed to handle these types of patient services conversations.
Although the conversations are written in the style of a phone call, Steve operates through a web-based text chat interface. It does not use speech recognition or text-to-speech.
Steve is built with Python and Flask, with an LLM accessed through the Groq API for open-ended conversational interactions.
The prototype supports several workflows, including:
Here is a demonstration using fictional patients:
▶️ Watch the Steve demo on YouTube
The most important architectural lesson I learned while building Steve was that not every interaction needs an LLM.
My central design rule became:
If a workflow is predictable, Python handles it and returns the response directly. The LLM handles what is genuinely open-ended.
Every message enters through a single Flask /chat route. That route checks a sequence of deterministic workflow handlers first.
If a handler recognizes and owns the interaction, it returns a response without calling the LLM. Only when none of the defined workflows handles the message does the application assemble the relevant context and call the model.
Here is a simplified illustration of that approach:
@app.route("/chat", methods=["POST"])
def chat():
response = handle_some_workflow(user_message, message_lower)
if response is not None:
return jsonify({"response": response})
system_with_context = "\n".join(
part for part in (system_prompt, pre_chart_context, ...) if part
)
completion = groq_create_completion(
messages=messages,
...
)
When the LLM is called, it does not receive just a bare conversation.
Python builds the system prompt and appends context blocks calculated for that particular turn. Depending on the interaction, these can include:
These context blocks are labeled as system-injected information, and the prompt instructs the model to use them rather than relying on its own assumptions.
The application evolved over 17 development sprints. app.py handles routing and session control, while separate modules contain workflows for post-hospital follow-ups, wellness visits, medication refills, lab orders, fax inquiries, and miscellaneous requests.
Those modules use state-machine-style logic to manage the different stages of each workflow.
I did not start with this architecture. Initially, I relied more heavily on the prompt and the model's ability to interpret instructions.
During development, I encountered several situations that changed how I approached the design.
A patient requested an order for a monthly Prolia shot.
Prolia is not a controlled substance. However, my prompt contained a detailed section about controlled-substance procedures, and the model incorrectly treated the request as one. It generated a medication schedule and an invented timeframe related to the patient's last office visit.
The problem was not simply that the model misunderstood a word. It was applying a nearby set of instructions to a situation where they did not belong.
My solution was to add a deterministic handler for non-controlled medication order requests rather than continuing to rely on prompt adjustments.
I originally asked the model to calculate which calendar date corresponded to each weekday.
It sometimes produced incorrect dates. For example, it offered Monday, September 1, even though September 1, 2026 was a Tuesday. It also occasionally suggested dates that had already passed.
I moved that responsibility into Python.
The application now calculates the next occurrence of each weekday, accounts for recognized office holidays, and provides the model with a literal lookup table.
Python calculates the dates. The LLM communicates them.
At the end of an interaction, Steve asks:
"Is there anything else I can help you with?"
Occasionally, when a patient responded with "No. Thank you," the model returned an empty response.
Closing a conversation is one of the most predictable parts of the interaction. I therefore moved that behavior into deterministic application logic.
These experiences reinforced a rule I now use when thinking about AI application development:
If a rule can reliably calculate or determine the answer, put that responsibility in code.
Identity checks, age calculations, office hours, eligibility windows, and calendar dates should not depend on an LLM improvising a response.
The LLM is useful for conversational flexibility and handling the many different ways people express themselves. It should not automatically become the authority for every business rule.
Several important workflow rules live in Python rather than relying exclusively on the system prompt.
Here are some examples.
Third-party callers: Someone calling about a patient must pass a simulated authorization-on-file check. If the caller is not listed as authorized, the workflow moves toward having the patient join the conversation. The patient must then verify their own last name and date of birth and provide consent before information is shared.
Minors: A date of birth that calculates to an age under 18 triggers a restriction. Scheduling cannot proceed until a parent or guardian is on the line and has identified themselves.
Office hours and holidays: Seven recognized holidays, including weekend-observance adjustments, are incorporated into the office-hours logic. Steve uses the same function to determine whether the office is open on weekends and holidays.
Medication questions: Steve does not explain what medications are used for. Those requests are directed toward a callback workflow.
Controlled substances: Requests follow a separate workflow based on the medication's schedule and the patient's last-visit timeframe. One path also includes a bridge-medication question after an appointment is booked.
It is important to distinguish between a simulated workflow and a real verification system.
For example, the authorization-on-file result is randomly generated because Steve does not connect to an actual electronic health record. The purpose was to develop and test the conversation logic, not to represent a compliant patient-information verification system.
Steve does not connect to an EHR or an actual scheduling platform.
As a result, many backend results are simulated. These include:
Appointments booked through Steve are saved to local JSON files. This allows the prototype to retrieve appointment information or handle a later rescheduling request.
One challenge with simulated data is that random results can make testing difficult.
A conversation might follow one path today and a different path tomorrow because the simulated result changed.
To address this, I added environment-variable overrides that force specific workflow branches. This allowed me to replay the same conversation and test the same conditions repeatedly.
I learned that randomness can be useful when simulating real-world variation, but reproducibility is essential when troubleshooting an application.
A significant amount of development time went into debugging.
The recurring problems were often straightforward Python issues rather than complicated AI failures:
elif statementsglobal declarations
A few examples were particularly memorable.
Some workflow modules needed access to the application's live state, including conversation history and patient information.
The modules accessed that state by importing app.
However, when Flask is launched with:
python app.py
Python loads the running file under the module name __main__.
When another module subsequently imports app, Python can load the same file again as a separate module. That second copy has its own globals, which are not the same as the live application's state.
The result was a strange bug: the application did not necessarily crash, but the workflow modules could behave as if the patient had never provided certain information.
I addressed this with:
sys.modules.setdefault("app", sys.modules[__name__])
It was a good reminder that some bugs are difficult to identify precisely because nothing visibly crashes.
My early intent detection relied on simple substring checks.
That created several unexpected matches:
"form" matched inside "metformin"
"no" matched inside "now" and "know"
"ave" matched inside "have"
"park" matched "Parker" when searching for a provider named Park
I changed the matching logic to use word boundaries:
def _contains_trigger(message_lower, triggers):
for trigger in triggers:
if re.search(r'\b' + re.escape(trigger) + r'\b', message_lower):
return True
return False
This improved matching for the scenarios I was testing, although it did not eliminate the broader limitations of regex-based intent detection.
Another problem occurred when someone said:
"Schedule a follow-up for my spouse and myself."
A name-capture pattern incorrectly extracted "and" and "myself" as a first and last name.
That incorrect capture then interfered with later logic intended to identify whether the caller was the patient.
I added checks to reject certain non-name tokens.
The larger lesson was that extracting names from unrestricted conversational text is more complicated than it initially appears.
I also encountered cases where the model response was cut off because it reached its token limit.
For example, a patient could receive a response ending with:
"...is there anything else I"
I added logic to detect truncated responses and trim incomplete output back to the last complete sentence. In the specific closing workflow, the application can complete the expected closing response deterministically.
Another issue involved API failures. Initially, a failed API request could expose raw provider error information, including status codes and quota details, to the user.
I changed the error handling so that the user receives a generic apology while the application logs the exception type for troubleshooting.
The application also supports multiple API keys through environment variables and rotates to another configured key when a request fails.
The important point is that credentials are not hard-coded into the application.
I want to be clear about what testing meant in this project.
Steve went through disciplined, scenario-based manual testing. It did not have a completed automated test suite.
My testing process included:
One improvement I would make next is converting those manually replayed conversations into automated transcript tests.
Many of the test cases already exist in the form of conversations I used during development. Turning them into automated tests would make regression testing more efficient and repeatable.
Building Steve was a valuable learning experience, but there are important limitations.
app.py file:
If I continued developing Steve, my priorities would be:
These are not small changes, but identifying them is part of understanding what it would take to move a prototype toward a more mature application.
After spending months developing and debugging Steve, these are the lessons I would carry into another project:
1. Decide what the model is allowed to decide.
Do not assume that the LLM should control every part of the interaction. Define its responsibilities deliberately.
2. Calculate what can be calculated.
Dates, eligibility windows, age checks, and office hours are better handled by predictable application logic.
3. A better prompt will not always fix a recurring problem.
If you find yourself repeatedly adjusting a prompt to address the same failure, consider whether the responsibility belongs in code instead.
4. Make randomness controllable.
Simulated outcomes are useful, but you need to be able to reproduce a failing scenario to troubleshoot it effectively.
5. Plan for unglamorous failures.
Truncated responses, API rate limits, empty replies, and error messages that expose internal details are all part of application development.
6. Keep track of recurring bugs.
Recognizing patterns such as overly broad regex expressions, incorrect logic ordering, and state-management problems can make debugging more efficient.
7. Be honest about what your application does and does not do.
A prototype with clearly documented limitations is more credible than one that makes unsupported claims.
My background is in healthcare informatics and data analytics, and I think that influenced how I approached this project.
An important part of analytical work is defining rules, identifying exceptions, understanding the underlying information, and checking results against expectations.
Those same habits proved valuable when developing an AI-assisted application.
The LLM contributed conversational flexibility, but the application needed predictable logic for the things that had to be handled consistently.
Steve is the largest coding project I have built, and it taught me more than I expected, particularly through the problems I encountered along the way.
It also reinforced an idea I find increasingly important as AI applications become more common:
Building a useful AI application isn't just about getting the model to produce a good response. It's about designing the surrounding application so that the right things happen for the right reasons.
I'd welcome feedback from other developers:
Thanks for reading. I'd be interested to hear about your own experiences building and testing AI-assisted applications.